aashutoshrathi/git-stalk-cli

Fix KeyError

Closed this issue · 8 comments

We are getting KeyError for Issue and Name.

Is this the error?
captura

Addressed in my pull request. Looking at the code I would also suggest updating the entire codebase to PEP8, as using comments beginning with # would be preferable to string comments.

event["payload"] JSON have the key as the issue only in few payloads. it's because of it. should the API be changed or the implementation?.
I am Interested in doing it.

@VANKINEENITAWRUN Try resolving it, I'll check the PR

When running stalk Grokzen you get the following stack trace back. It do not cause this on every user, but currently on mine.

Contributions Today:                                                                            
Traceback (most recent call last):                                                      
  File "/home/grok/.virtualenvs/git-stalk/bin/stalk", line 11, in <module>
    load_entry_point('git-stalk', 'console_scripts', 'stalk')()                         
  File "/home/grok/code/github/git-stalk-cli/git_stalk/stalk.py", line 428, in run
    show_contri(args)
  File "/home/grok/code/github/git-stalk-cli/git_stalk/stalk.py", line 391, in show_contri
    get_contributions(user, latest, text_date)
  File "/home/grok/code/github/git-stalk-cli/git_stalk/stalk.py", line 206, in get_contributions
    get_details(event),
  File "/home/grok/code/github/git-stalk-cli/git_stalk/stalk.py", line 73, in get_details
    "IssuesEvent": event["payload"]["issue"]["title"],                    
KeyError: 'issue'                                              

@Grokzen happened same with me

@aashutoshrathi @Grokzen it happens with many users. The JSON that GitHub API sends doesn't have all the fields always. I tried adding KEY ERROR try catch in every line then it worked but Travis tests fail for the function being too complex.
screenshot from 2018-10-30 14-12-38

No worries, we will fix the Travis later, lets fix this first