Skip to content

Fix crash on null repository in PR history#29

Merged
jeffreyksmithjr merged 1 commit into
mainfrom
fix/null-repository-crash
Feb 17, 2026
Merged

Fix crash on null repository in PR history#29
jeffreyksmithjr merged 1 commit into
mainfrom
fix/null-repository-crash

Conversation

@jeffreyksmithjr

Copy link
Copy Markdown
Contributor

Summary

  • Fix TypeError: 'NoneType' object is not subscriptable when a user's PR history includes PRs to deleted or inaccessible repositories (Error while accessing contribution data #28)
  • The GitHub GraphQL API returns null for the repository field on such PR nodes; we now skip them gracefully in all three PR-parsing loops in github_client.py
  • Added tests covering the null-repository scenario for both fetch_user_merged_prs and get_user_contribution_data

Test plan

  • All 221 tests pass (including 2 new tests for this fix)
  • 92% coverage maintained
  • Lint (ruff) and type check (mypy) clean
  • Verified live: good-egg score Kroppeb --repo 2ndSetAI/good-egg now returns HIGH (81%) instead of crashing

Fixes #28

The GitHub GraphQL API returns null for the repository field on PR nodes
when the repo has been deleted or the token lacks access. Skip these
nodes instead of crashing with TypeError.

Fixes #28
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @jeffreyksmithjr, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug that caused the application to crash when encountering pull requests associated with deleted or inaccessible repositories in a user's GitHub history. By adding explicit checks for null repository objects returned by the GitHub GraphQL API, the system now gracefully skips these invalid entries, ensuring stability and preventing TypeError exceptions. New tests have been added to validate this robust handling.

Highlights

  • Crash Fix: Resolved a TypeError: 'NoneType' object is not subscriptable that occurred when processing PR history containing references to deleted or inaccessible repositories.
  • Null Repository Handling: Implemented graceful skipping of pull request nodes where the repository field is null in the GitHub GraphQL API response, specifically within github_client.py.
  • Test Coverage: Introduced new tests to cover the null-repository scenario for both fetch_user_merged_prs and get_user_contribution_data functions.
Changelog
  • src/good_egg/github_client.py
    • Added 'if repo is None: continue' checks in 'fetch_user_merged_prs' and 'get_user_contribution_data' to prevent errors when a repository object is null.
  • tests/test_github_client.py
    • Introduced 'test_fetch_user_merged_prs_skips_null_repository' to verify that 'fetch_user_merged_prs' correctly ignores PRs with null repositories.
    • Added 'test_null_repository_skipped' to confirm that 'get_user_contribution_data' also skips PRs with null repositories.
Activity
  • All 221 existing tests passed, with 2 new tests added for this fix.
  • Code coverage was maintained at 92%.
  • Linting with ruff and type checking with mypy passed without issues.
  • The fix was verified live, confirming that the good-egg score command no longer crashes for the specified scenario.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions

Copy link
Copy Markdown

🥚 Good Egg: HIGH Trust

Score: 80%

Top Contributions

Repository PRs Language Stars
2ndSetAI/good-egg 14 Python 16
jeffreyksmithjr/verskyt 9 Python 2
jeffreyksmithjr/galapagos_nao 7 Elixir 21
aws-samples/aws-big-data-blog 3 Java 895
pytorch/pytorch.github.io 2 HTML 276
nerves-project/nerves_examples 1 Elixir 402
kilimchoi/engineering-blogs 1 Ruby 37129
kdeldycke/plumage 1 CSS 55

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request effectively addresses the reported crash by adding null checks for the 'repository' field in github_client.py. The new tests adequately cover the null-repository scenario for both fetch_user_merged_prs and get_user_contribution_data, ensuring the fix works as expected. The changes are well-implemented and maintain code quality.

@jeffreyksmithjr

Copy link
Copy Markdown
Contributor Author

Thanks @Kroppeb for filing. It now works and you score a respectable HIGH (81%) on this repo.

@jeffreyksmithjr jeffreyksmithjr merged commit 026775d into main Feb 17, 2026
2 checks passed
@jeffreyksmithjr jeffreyksmithjr deleted the fix/null-repository-crash branch February 17, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error while accessing contribution data

1 participant