Skip to content

fix: convert app_id to string before login_as_app_installation call#413

Merged
zkoppert merged 1 commit intomainfrom
jm_fix_app_id
Mar 4, 2026
Merged

fix: convert app_id to string before login_as_app_installation call#413
zkoppert merged 1 commit intomainfrom
jm_fix_app_id

Conversation

@jmeridth
Copy link
Collaborator

@jmeridth jmeridth commented Mar 3, 2026

Pull Request

Proposed Changes

What

Wrapped gh_app_id with str() in the login_as_app_installation call in auth.py, and added a targeted test for integer app_id inputs. Existing tests were also tightened to assert on exact call arguments.

Why

When gh_app_id is passed as an integer, PyJWT raises a TypeError on the iss claim during JWT encoding because it expects a string. This surfaces at runtime when the environment variable is parsed as an int rather than str.

Notes

  • Only gh_app_id is converted; gh_app_installation_id is left as-is since login_as_app_installation accepts it in its original form — reviewers should verify this is intentional
  • The existing tests previously used assert_called_once() without argument checks, so bugs like this were invisible; the tightened assertions now catch argument type mismatches
  • Mirrors the fix in fix: convert app_id to string before login_as_app_installation call cleanowners#340

Readiness Checklist

Author/Contributor

  • If documentation is needed for this change, has that been included in this pull request
  • run make lint and fix any issues that you have introduced
  • run make test and ensure you have test coverage for the lines you are introducing

### What

Wrapped `gh_app_id` with `str()` in the `login_as_app_installation` call
in auth.py, and added a targeted test for integer app_id inputs. Existing
tests were also tightened to assert on exact call arguments.

### Why

When `gh_app_id` is passed as an integer, PyJWT raises a TypeError on the
`iss` claim during JWT encoding because it expects a string. This surfaces
at runtime when the environment variable is parsed as an int rather than str.

### Notes

- Only `gh_app_id` is converted; `gh_app_installation_id` is left as-is
  since `login_as_app_installation` accepts it in its original form —
  reviewers should verify this is intentional
- The existing tests previously used `assert_called_once()` without argument
  checks, so bugs like this were invisible; the tightened assertions now
  catch argument type mismatches

Signed-off-by: jmeridth <jmeridth@gmail.com>
@jmeridth jmeridth self-assigned this Mar 3, 2026
@jmeridth jmeridth requested a review from zkoppert as a code owner March 3, 2026 10:07
Copilot AI review requested due to automatic review settings March 3, 2026 10:07
@github-actions github-actions bot added the fix label Mar 3, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a GitHub App authentication runtime error by ensuring the App ID is passed as a string when authenticating via login_as_app_installation, and strengthens the unit tests to catch argument-type mismatches.

Changes:

  • Cast gh_app_id to str in auth_to_github() before calling login_as_app_installation(...).
  • Tighten existing auth tests to assert exact login_as_app_installation(...) call arguments and add a test for integer app_id.
  • Add .gitignore entries for local Claude AI files and update the PR template checklist.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
auth.py Converts gh_app_id to string for the login_as_app_installation(...) call.
test_auth.py Tightens call-argument assertions and adds coverage for integer gh_app_id.
.gitignore Ignores .claude/*.local.* files.
.github/pull_request_template.md Removes a checklist item from the PR template.

@zkoppert
Copy link
Collaborator

zkoppert commented Mar 3, 2026

@jmeridth Were we able to test this out?

@jmeridth
Copy link
Collaborator Author

jmeridth commented Mar 3, 2026

@jmeridth Were we able to test this out?

Yes. Confirmed with the cleanowners fix I merged and deployed to my own org. This fix is necessitated all of our actions.

Copy link
Collaborator

@zkoppert zkoppert left a comment

Choose a reason for hiding this comment

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

🚀

@zkoppert zkoppert merged commit aff93cf into main Mar 4, 2026
43 checks passed
@zkoppert zkoppert deleted the jm_fix_app_id branch March 4, 2026 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants