Skip to content

Commit

Permalink
Merge pull request #5 from Uninett/custom-fields-key-error
Browse files Browse the repository at this point in the history
Check for existence of keys in serialized incident
  • Loading branch information
johannaengland authored Feb 22, 2023
2 parents 9b4763b + 3937dae commit 881fff4
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/argus_ticket_jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
LOG = logging.getLogger(__name__)


__version__ = "1.0"
__version__ = "1.0.1"
__all__ = [
"JiraPlugin",
]
Expand Down Expand Up @@ -55,23 +55,27 @@ def get_custom_fields(
incident_tags = JiraPlugin.convert_tags_to_dict(serialized_incident["tags"])
custom_fields = {}
if "custom_fields_set" in ticket_information.keys():
for key, value in ticket_information["custom_fields_set"].items():
for key, field in ticket_information["custom_fields_set"].items():
field_id = map.get(key, None)
if field_id:
custom_fields[field_id] = value
custom_fields[field_id] = field

custom_fields_mapping = ticket_information.get("custom_fields_mapping", {})
for key, value in custom_fields_mapping.items():
for key, field in custom_fields_mapping.items():
field_id = map.get(key, None)
if field_id:
if type(value) is dict:
if type(field) is dict:
# Information can be found in tags
custom_fields[field_id] = incident_tags[value["tag"]]
custom_field = incident_tags.get(field["tag"], None)
if custom_field:
custom_fields[field_id] = custom_field
else:
# Infinity means that the incident is still open
if serialized_incident[value] == "infinity":
continue
custom_fields[field_id] = serialized_incident[value]
custom_field = serialized_incident.get(field, None)
if custom_field:
# Infinity means that the incident is still open
if custom_field == "infinity":
continue
custom_fields[field_id] = custom_field

return custom_fields

Expand Down

0 comments on commit 881fff4

Please sign in to comment.