Skip to content

TypeError: 'NoneType' object is not subscriptable #584

@fpistm

Description

@fpistm

Describe the bug

Hi,
Since some time I face an issue when getting some PR metrics.
Here the error:

An error occurred processing review comments. Perhaps the review contains a ghost user. 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/action/workspace/issue_metrics.py", line 407, in <module>
    main()
    ~~~~^^
  File "/action/workspace/issue_metrics.py", line 341, in main
    issues_with_metrics, num_issues_open, num_issues_closed = get_per_issue_metrics(
                                                              ~~~~~~~~~~~~~~~~~~~~~^
        issues,
        ^^^^^^^
    ...<5 lines>...
        env_vars=env_vars,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/action/workspace/issue_metrics.py", line 142, in get_per_issue_metrics
    pull_request = issue.issue.pull_request()  # type: ignore
  File "/usr/local/lib/python3.13/site-packages/github3/issues/issue.py", line 312, in pull_request
    return self._instance_or_null(pulls.PullRequest, json)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/github3/models.py", line 151, in _instance_or_null
    return instance_class(json, self)
  File "/usr/local/lib/python3.13/site-packages/github3/models.py", line 52, in __init__
    self._update_attributes(json)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.13/site-packages/github3/pulls.py", line 713, in _update_attributes
    super()._update_attributes(pull)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.13/site-packages/github3/pulls.py", line 212, in _update_attributes
    self.head = Head(pull["head"], self)
                ~~~~^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/github3/models.py", line 52, in __init__
    self._update_attributes(json)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.13/site-packages/github3/pulls.py", line 74, in _update_attributes
    self._repo_owner = repo["owner"]["login"]
                       ~~~~~~~~~~~~~^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

Maybe it is related to sigmavirus24/github3.py#1161

To Reproduce

the job request

jobs:
  pr_metrics:
    name: pr metrics
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@main
      - name: Run issue-metrics tool
        uses: github/issue-metrics@v3
        env:
          GH_TOKEN: ${{ secrets.ISSUE_METRICS }}
          SEARCH_QUERY: 'repo:zephyrproject-rtos/zephyr is:pr created:2025-01-01..2025-12-31 label:"platform: STM32"'
          HIDE_TIME_TO_ANSWER: true

Expected behavior

No python error. Script runs properly.

Screenshots

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions