chaoss / grimoirelab-elk

GNU General Public License v3.0
59 stars 120 forks source link

[JIRA] p2o enrich data fails when jira user is anonymous #931

Closed teragopher closed 4 years ago

teragopher commented 4 years ago

command: p2o.py --enrich --index sds-danos-jira-raw --index-enrich sds-danos-jira -e [redacted] --only-enrich --refresh-identities --no_incremental --bulk-size 500 --scroll-size 500 --db-host [redacted] --db-sortinghat [redacted] --db-user [redacted] --db-password [redacted] jira https://danosproject.atlassian.net/

This results in error

Traceback (most recent call last):
  File "/repos/grimoirelab-elk/grimoire_elk/elk.py", line 531, in enrich_backend
    enrich_count = enrich_items(ocean_backend, enrich_backend)
  File "/repos/grimoirelab-elk/grimoire_elk/elk.py", line 319, in enrich_items
    total = enrich_backend.enrich_items(ocean_backend)
  File "/repos/grimoirelab-elk/grimoire_elk/enriched/jira.py", line 449, in enrich_items
    rich_item_comments = self.get_rich_item_comments(comments, eitem_creator)
  File "/repos/grimoirelab-elk/grimoire_elk/enriched/jira.py", line 411, in get_rich_item_comments
    ecomment.update(self.get_item_sh(comment, ['author', 'updateAuthor'], comment['created']))
  File "/repos/grimoirelab-elk/grimoire_elk/enriched/jira.py", line 125, in get_item_sh
    identity = self.get_sh_identity(item, rol)
  File "/repos/grimoirelab-elk/grimoire_elk/enriched/jira.py", line 94, in get_sh_identity
    user = item[identity_field]
KeyError: 'author'

After taking a look at the raw item that was failing to be enriched, turns out the comment doesn't have an author field and get_sh_identity doesn't check to see if it is present or not

"comments_data": [
            {
                "body": "Write message here",
                "created": "2019-11-22T03:04:18.765-0800",
                "id": "10033",
                "jsdPublic": false,
                "self": "https://danosproject.atlassian.net/rest/api/2/issue/10027/comment/10033",
                "updated": "2019-11-22T03:04:18.765-0800"
            }
        ],