Skip to content

Safely coerce responseHeaders to int#2697

Merged
EnricoMi merged 3 commits into
PyGithub:mainfrom
adosibalo:hotfix/headers-rates-to-int
Aug 3, 2023
Merged

Safely coerce responseHeaders to int#2697
EnricoMi merged 3 commits into
PyGithub:mainfrom
adosibalo:hotfix/headers-rates-to-int

Conversation

@adosibalo

Copy link
Copy Markdown
Contributor

Today for the first time I got the following traceback in my CI build. I'm not sure what changed, but casting these headers as float prior to int seems innocent enough.

Traceback (most recent call last):
  File "/home/circleci/project/.circleci/update_badge.py", line 23, in <module>
    cov_badge.edit(files={"coverage.svg": InputFileContent(coverage_badge)})
  File "/home/circleci/.pyenv/versions/3.10.12/lib/python3.10/site-packages/github/Gist.py", line 258, in edit
    headers, data = self._requester.requestJsonAndCheck(
  File "/home/circleci/.pyenv/versions/3.10.12/lib/python3.10/site-packages/github/Requester.py", line 399, in requestJsonAndCheck
    *self.requestJson(
  File "/home/circleci/.pyenv/versions/3.10.12/lib/python3.10/site-packages/github/Requester.py", line 499, in requestJson
    return self.__requestEncode(cnx, verb, url, parameters, headers, input, encode)
  File "/home/circleci/.pyenv/versions/3.10.12/lib/python3.10/site-packages/github/Requester.py", line 582, in __requestEncode
    int(responseHeaders[Consts.headerRateRemaining]),
ValueError: invalid literal for int() with base 10: '2499.0'

@EnricoMi EnricoMi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's leave some comment on why we have this ugly code here.

Comment thread github/Requester.py
Comment thread github/Requester.py
adosibalo and others added 2 commits July 26, 2023 09:15
Co-authored-by: Enrico Minack <[email protected]>
Co-authored-by: Enrico Minack <[email protected]>
@adosibalo adosibalo requested a review from EnricoMi July 27, 2023 21:30

@EnricoMi EnricoMi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@EnricoMi EnricoMi merged commit 1922ea6 into PyGithub:main Aug 3, 2023
EnricoMi added a commit that referenced this pull request Aug 3, 2023
@EnricoMi

EnricoMi commented Aug 3, 2023

Copy link
Copy Markdown
Collaborator

Fix released as v1.59.1.

EnricoMi added a commit that referenced this pull request Aug 3, 2023
@EnricoMi

EnricoMi commented Aug 3, 2023

Copy link
Copy Markdown
Collaborator

Fix released as v2.0.1-preview.

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.

2 participants