mirror of
https://github.com/hwchase17/langchain.git
synced 2025-04-29 04:16:02 +00:00
community: Made some Jira fields optional for agent to work correctly (#29876)
**Description:** Two small changes have been proposed here: (1) Previous code assumes that every issue has a priority field. If an issue lacks this field, the code will raise a KeyError. Now, the code checks if priority exists before accessing it. If priority is missing, it assigns None instead of crashing. This prevents runtime errors when processing issues without a priority. (2) Also If the "style" field is missing, the code throws a KeyError. `.get("style", None)` safely retrieves the value if present. **Issue:** #29875 **Dependencies:** N/A
This commit is contained in:
parent
ca7eccba1f
commit
92b415a9f6
@ -84,7 +84,10 @@ class JiraAPIWrapper(BaseModel):
|
|||||||
key = issue["key"]
|
key = issue["key"]
|
||||||
summary = issue["fields"]["summary"]
|
summary = issue["fields"]["summary"]
|
||||||
created = issue["fields"]["created"][0:10]
|
created = issue["fields"]["created"][0:10]
|
||||||
priority = issue["fields"]["priority"]["name"]
|
if "priority" in issue["fields"]:
|
||||||
|
priority = issue["fields"]["priority"]["name"]
|
||||||
|
else:
|
||||||
|
priority = None
|
||||||
status = issue["fields"]["status"]["name"]
|
status = issue["fields"]["status"]["name"]
|
||||||
try:
|
try:
|
||||||
assignee = issue["fields"]["assignee"]["displayName"]
|
assignee = issue["fields"]["assignee"]["displayName"]
|
||||||
@ -121,15 +124,9 @@ class JiraAPIWrapper(BaseModel):
|
|||||||
key = project["key"]
|
key = project["key"]
|
||||||
name = project["name"]
|
name = project["name"]
|
||||||
type = project["projectTypeKey"]
|
type = project["projectTypeKey"]
|
||||||
style = project["style"]
|
style = project.get("style", None)
|
||||||
parsed.append(
|
parsed.append(
|
||||||
{
|
{"id": id, "key": key, "name": name, "type": type, "style": style}
|
||||||
"id": id,
|
|
||||||
"key": key,
|
|
||||||
"name": name,
|
|
||||||
"type": type,
|
|
||||||
"style": style,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
return parsed
|
return parsed
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user