Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

self.avatar_url = user["avatar_url"] TypeError: 'NoneType' object is not subscriptable #173

Closed
kolbeface opened this issue Jul 3, 2024 · 6 comments · Fixed by #184
Closed
Assignees
Labels
bug Something isn't working keep

Comments

@kolbeface
Copy link

kolbeface commented Jul 3, 2024

Describe the bug

I seem to be failing when subscripting through my stale repos. I believe the issue is that a ghost user created this particular repo. An older version of your code seems to not have this issue.

Here is the full output with some redacted repository information.
I believe it is failing on repository GG/light which was created by Bitrise Buildbot this bot is not a part of our org and I believe might be seen as a ghost user here is possibly a similar issue
Run github/stale-repos@v1 /usr/bin/docker run --name ghcriogithubstale_reposv1_056a4e --label 16a7a4 --workdir /github/workspace --rm -e "GH_TOKEN" -e "ORGANIZATION" -e "EXEMPT_TOPICS" -e "INACTIVE_DAYS" -e "ACTIVITY_METHOD" -e "ADDITIONAL_METRICS" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/security_services/security_services":"/github/workspace" ghcr.io/github/stale_repos:v1 Starting stale repo search... Exempt topics: ['keep', 'template'] https://github.com/GG/repo-Android: 3717 days inactive https://github.com/GG/repo: 3813 days inactive https://github.com/GG/repo-ios: 3449 days inactive https://github.com/GG/repo-spain-ios: 2986 days inactive https://github.com/GG/repo: 3393 days inactive https://github.com/GG/repo-automation: 504 days inactive https://github.com/GG/repo-styled: 2097 days inactive https://github.com/GG/repo-policy-reporter: 603 days inactive https://github.com/GG/repo: 418 days inactive https://github.com/GG/repo-ios: 1139 days inactive https://github.com/GG/repo-metrics: 1735 days inactive https://github.com/GG/repo-exercise-ios: 734 days inactive https://github.com/GG/repo: 1330 days inactive https://github.com/GG/repo-exercise-android: 1898 days inactive https://github.com/GG/repo-service: 568 days inactive https://github.com/GG/repo-wm-business-v2: 413 days inactive https://github.com/GG/repo-tests: 559 days inactive https://github.com/GG/repo-tf: 399 days inactive https://github.com/GG/repo: 545 days inactive https://github.com/GG/repo-jobs: 617 days inactive https://github.com/GG/repo-analytics: 412 days inactive https://github.com/GG/light: 435 days inactive Traceback (most recent call last): File "/action/workspace/stale_repos.py", line 408, in <module> main() File "/action/workspace/stale_repos.py", line 55, in main inactive_repos = get_inactive_repos( ^^^^^^^^^^^^^^^^^^^ File "/action/workspace/stale_repos.py", line 146, in get_inactive_repos repo_data = set_repo_data( ^^^^^^^^^^^^^^ File "/action/workspace/stale_repos.py", line 399, in set_repo_data repo_data["days_since_last_release"] = get_days_since_last_release(repo) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/action/workspace/stale_repos.py", line 167, in get_days_since_last_release last_release = next(repo.releases()) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/github3/structs.py", line 142, in __next__ return next(self.__i__) ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/github3/structs.py", line 131, in __iter__ yield cls(i) ^^^^^^ File "/usr/local/lib/python3.12/site-packages/github3/models.py", line 52, in __init__ self._update_attributes(json) File "/usr/local/lib/python3.12/site-packages/github3/repos/release.py", line 102, in _update_attributes self.author = users.ShortUser(release["author"], self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/github3/models.py", line 52, in __init__ self._update_attributes(json) File "/usr/local/lib/python3.12/site-packages/github3/users.py", line 309, in _update_attributes self.avatar_url = user["avatar_url"] ~~~~^^^^^^^^^^^^^^ TypeError: 'NoneType' object is not subscriptable

Here is the problematic code:

name: stale repo identifier

on:
  workflow_dispatch:

jobs:
  build:
    name: stale repo identifier
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v3

    - name: Run stale_repos tool
      uses: github/stale-repos@v1
      env:
        GH_TOKEN: ${{ secrets.gh_token }}
        ORGANIZATION: ${{ secrets.organization }}
        EXEMPT_TOPICS: "keep,template"
        INACTIVE_DAYS: 365
        ACTIVITY_METHOD: "pushed"
        ADDITIONAL_METRICS: "release,pr"
    - name: Create issue
      uses: peter-evans/create-issue-from-file@v5
      with:
        title: Stale repository report
        content-filepath: ./stale_repos.md
        assignees: <user_name>

And here is an older version that behaves as expected:

name: stale repo identifier

on:
  workflow_dispatch:
  schedule:
    - cron: '0 12 1 */3 *'

jobs:
  build:
    name: stale repo identifier
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v3

    - name: Run stale_repos tool
      uses: docker://ghcr.io/github/stale_repos:v1
      env:
        GH_TOKEN: ${{ secrets.gh_token }}
        ORGANIZATION: ${{ secrets.organization }}
        INACTIVE_DAYS: 365

    - name: Create issue
      uses: peter-evans/create-issue-from-file@v4
      with:
        title: Stale repository report
        content-filepath: ./stale_repos.md
        assignees: sn0rlaxxx

To Reproduce

run the program on a repo built by a ghost user, in our case the user is
Bitrise Buildbot

Expected behavior

Expected behavior is to create a github issue with stale repos

Screenshots

No response

Additional context

No response

@kolbeface kolbeface added the bug Something isn't working label Jul 3, 2024
Copy link

This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the Stale label Jul 25, 2024
@zkoppert zkoppert self-assigned this Jul 25, 2024
@zkoppert zkoppert added keep and removed Stale labels Jul 25, 2024
@zkoppert
Copy link
Member

Started looking at this today.

@zkoppert
Copy link
Member

Got a potential fix for this in #184. @kolbeface Any thoughts on this? Would you be able to test if this fixes your issue?

@kolbeface
Copy link
Author

kolbeface commented Jul 26, 2024

@zkoppert if a ghost user is encountered will it still add the stale repo to the list? I tried to solve this problem myself but I got a bit lost in the github3 code. Still a bit of a novice. I appreciate you looking into this!

@zkoppert
Copy link
Member

Yes, it will still add the repo to the list but it will not be able to compute the last release or pr details.

No worries, I also get lost in that code. 😁

@kolbeface
Copy link
Author

Well in that case, I love it! Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working keep
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants