fix: cast JWT iss claim to string for PyJWT 2.12+ compatibility#6
Merged
Conversation
PyJWT 2.12+ enforces that the 'iss' claim must be a string per RFC 7519
Section 4.1.1 (StringOrURI). Previously self.id (an int) was passed
directly, which worked with older PyJWT but fails with:
TypeError: Issuer (iss) must be a string.
This is safe for all PyJWT versions — older versions accept both int and
str, and GitHub's API matches on value regardless of JSON type.
There was a problem hiding this comment.
Pull request overview
This PR updates JWT generation in GitHubApp to ensure the iss (issuer) claim is always a string, maintaining compatibility with PyJWT 2.12+’s stricter claim type enforcement.
Changes:
- Cast
self.idtostrwhen building the JWT payload (issclaim). - Update the unit test to expect
"iss": "123"instead of an integer.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/githubapp/core.py |
Ensures JWT iss claim is encoded as a string for PyJWT 2.12+ compatibility. |
tests/test_core.py |
Updates JWT payload assertion to match the new iss string type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses review feedback — str(None) would produce 'None' as the issuer, which passes PyJWT's type check but gets rejected by GitHub. Raise GitHubAppError with a clear message instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
self.idtostr()in_create_jwt()payload to satisfy PyJWT 2.12+ type enforcement on theissclaimContext
PyJWT 2.12+ enforces that the
iss(issuer) claim must be a string, per RFC 7519 Section 4.1.1 (StringOrURI). Previouslyself.id(anintfromgithub_app_id) was passed directly, which worked with older PyJWT versions but fails with:Why this is safe
intandstrforiss— no breakage12345vs"12345")issas StringOrURI — string is the correct typeTest plan
test_create_jwt_payload_structureto expect"iss": "123"instead of"iss": 123