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:
dokato 2025-02-20 17:10:11 +00:00 committed by GitHub
parent ca7eccba1f
commit 92b415a9f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -84,7 +84,10 @@ class JiraAPIWrapper(BaseModel):
key = issue["key"]
summary = issue["fields"]["summary"]
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"]
try:
assignee = issue["fields"]["assignee"]["displayName"]
@ -121,15 +124,9 @@ class JiraAPIWrapper(BaseModel):
key = project["key"]
name = project["name"]
type = project["projectTypeKey"]
style = project["style"]
style = project.get("style", None)
parsed.append(
{
"id": id,
"key": key,
"name": name,
"type": type,
"style": style,
}
{"id": id, "key": key, "name": name, "type": type, "style": style}
)
return parsed