Skip to content

Linter crashes with BadAttributeException when processing PR comments (from deleted users?) #30936

@phreed

Description

@phreed

Bug:

Description:

The staged-recipes linter is crashing with a BadAttributeException when trying to process PR comments.
Possibly from deleted user accounts or other inaccessible user data.

Error Details:

Traceback (most recent call last):
  File "/home/runner/work/staged-recipes/staged-recipes/.github/workflows/scripts/linter.py", line 312, in <module>
    lints, hints, extra_edits = _lint_recipes(gh, pr)
                                ~~~~~~~~~~~~~^^^^^^^^
  File "/home/runner/work/staged-recipes/staged-recipes/.github/workflows/scripts/linter.py", line 200, in _lint_recipes
    commenters = {comment.user.login.lower() for comment in issue_comments}
                  ^^^^^^^^^^^^
  File "/home/runner/micromamba/envs/lint/lib/python3.13/site-packages/github/IssueComment.py", line 168, in user
    return self._user.value
           ^^^^^^^^^^^^^^^^
  File "/home/runner/micromamba/envs/lint/lib/python3.13/site-packages/github/GithubObject.py", line 221, in value
    raise BadAttributeException(self.__value, self.__expectedType, self.__exception)

Expected Behavior:
The linter should gracefully handle comments from deleted or inaccessible users and continue processing the PR.

Actual Behavior:
The linter crashes completely, preventing PR validation from completing.

Reproduction:
This occurs on PR #30887 when running in GitHub Actions, but not when running pixi run lint locally.

Proposed Solution:
Add error handling around the user access in lines 200-201 of .github/workflows/scripts/linter.py.

# Handle cases where user might be None (deleted users, etc.)
commenters = set()
for comment in issue_comments:
    try:
        if comment.user and comment.user.login:
            commenters.add(comment.user.login.lower())
    except (AttributeError, github.GithubException):
        # Skip comments from deleted users or other inaccessible cases
        continue

for review in review_comments:
    try:
        if review.user and review.user.login:
            commenters.add(review.user.login.lower())
    except (AttributeError, github.GithubException):
        # Skip reviews from deleted users or other inaccessible cases
        continue

Environment:

  • This occurs in GitHub Actions
  • PyGithub version: (as installed in the lint environment)
  • Python 3.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions