jstrieb/github-stats

Error generating images

jswny opened this issue · 6 comments

jswny commented

I've forked the repo into my own repo here and I've done all the setup steps. The Generate images actions step fails. The log contains hundreds of lines that say A path returned 202. Retrying..., and the following error:

Traceback (most recent call last):
  File "generate_images.py", line 105, in <module>
    asyncio.run(main())
  File "/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "generate_images.py", line 101, in main
    await asyncio.gather(generate_languages(s), generate_overview(s))
  File "generate_images.py", line 41, in generate_overview
    changed = (await s.lines_changed)[0] + (await s.lines_changed)[1]
  File "/home/runner/work/github-stats/github-stats/github_stats.py", line 437, in lines_changed
    author = author_obj.get("author", {}).get("login", "")
AttributeError: 'str' object has no attribute 'get'

Didn't mean to close this. Apparently putting "Fix #3" in the commit message auto-closes an issue.

I just pushed something I hope will fix the issue, but I am not totally sure. To be precise: I changed the infinite loop that generates all of the 202s into a loop with a max number of tries that returns incomplete data as a fallback. Please merge the change into your fork and see if it works better.

Also, for more info, see #3.

jswny commented

@jstrieb Thanks for looking at this! Unfortunately, I get the same result with the hundreds of 202 messages, and the same error from above. I also get this every so often There were too many 202s. Data for this repository will be incomplete.

Since the process still exits with error code 1 in the actions job, the commit to repo is not executed. Is it possible you need to make the process exit cleanly if there are too many 202s so it still commits something?

Thanks for the quick response on this. I'm assuming that there is a JSON error message response that the program is trying to iterate over as if it was well-formed author data. I've added what I hope is a fix, but it's hard to know for sure whether it will work for your situation without being able to replicate the error locally.

jswny commented

Thanks! It seems to work now!

Glad you were able to get it working! These fixes will definitely help this code work better for others in the future, so I appreciate you working with me to iron out the bugs. Hopefully GitHub adds contributor/viewer statistics to the v4 GraphQL API so that it's a little less glitchy.

Thanks for using the project!

Got this on first run but after changing the readme and commiting it worked