guilhemmarchand / TA-jira-service-desk-simple-addon

Atlasian JIRA add-on for Splunk alert actions
11 stars 8 forks source link

Error reported in logs when the issue MD5 is equal, the alert continues to trigger and dedup is disabled #77

Closed guilhemmarchand closed 3 years ago

guilhemmarchand commented 3 years ago

Error reported in logs when the issue MD5 is equal, the alert continues to trigger and dedup is disabled

Symptoms:

2021-04-18 21:34:05,562 ERROR pid=21694 tid=MainThread file=cim_actions.py:message:243 | sendmodaction - signature="Backlog KVstore saving has failed!. url=https://localhost:8089/servicesNS/nobody/TA-jira-service-desk-simple-addon/storage/collections/data/kv_jira_issues_backlog, data={"_key": "f16cd3b4da979dc89a71801f6e189f8a", "jira_md5": "f16cd3b4da979dc89a71801f6e189f8a", "ctime": "1618781645.5262454", "mtime": "1618781645.526261", "status": "created", "jira_id": "10752", "jira_key": "ACME-275", "jira_self": "https://localhost:8081/rest/api/2/issue/10752"}, HTTP Error=409, content=<?xml version="1.0" encoding="UTF-8"?>
<response>
  <messages>
    <msg type="ERROR">A document with the same key and user already exists.</msg>
  </messages>
</response>
" action_name="jira_service_desk" search_name="Test JIRA brand new" sid="scheduler__admin__search__RMD5f1e3e5fd9644f564_at_1618781640_71" rid="0" app="search" user="admin" action_mode="saved" action_status="failure"

The error is located here:

line 695 in TA-jira-service-desk-simple-addon/bin/ta_jira_service_desk_simple_addon/modalert_jira_service_desk_helper.py:

                    if jira_dedup_md5_found:
                        record = '{"_key": "' + jira_md5sum + '", "jira_md5": "' + jira_md5sum + '", "ctime": "' \
                                + str(time.time()) + '", "mtime": "' \
                                + str(time.time()) + '", "status": "created", "jira_id": "' \
                                + jira_created_id + '", "jira_key": "' \
                                + jira_created_key + '", "jira_self": "' + jira_created_self + '"}'
                        helper.log_debug('record={}'.format(record))
                    else:
                        record = '{"_key": "' + jira_md5sum + '", "jira_md5": "' + jira_md5sum + '", "ctime": "' \
                                + str(time.time()) + '", "mtime": "' + str(time.time()) \
                                + '", "status": "created", "jira_id": "' + jira_created_id \
                                + '", "jira_key": "' + jira_created_key + '", "jira_self": "' + jira_created_self + '"}'
                        helper.log_debug('record={}'.format(record))

Which should be replaced by:

                    if jira_dedup_md5_found:
                        record = '{"jira_md5": "' + jira_md5sum + '", "ctime": "' \
                                + str(time.time()) + '", "mtime": "' \
                                + str(time.time()) + '", "status": "created", "jira_id": "' \
                                + jira_created_id + '", "jira_key": "' \
                                + jira_created_key + '", "jira_self": "' + jira_created_self + '"}'
                        helper.log_debug('record={}'.format(record))
                    else:
                        record = '{"_key": "' + jira_md5sum + '", "jira_md5": "' + jira_md5sum + '", "ctime": "' \
                                + str(time.time()) + '", "mtime": "' + str(time.time()) \
                                + '", "status": "created", "jira_id": "' + jira_created_id \
                                + '", "jira_key": "' + jira_created_key + '", "jira_self": "' + jira_created_self + '"}'
                        helper.log_debug('record={}'.format(record))