Skip to content

fix: convert gh_app_id to string before login_as_app_installation call#121

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

fix: convert gh_app_id to string before login_as_app_installation call#121
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, added targeted tests for integer app_id inputs, and tightened existing test assertions to verify exact call arguments. Also added .claude local files to .gitignore.

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

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,
added targeted tests for integer app_id inputs, and tightened existing test
assertions to verify exact call arguments. Also added .claude local files to
.gitignore.

### 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
- The existing test previously used assert_called_once() without argument checks, so type mismatches like this were invisible; the tightened assertions now catch them
- Mirrors the fix in github-community-projects/cleanowners#340

Signed-off-by: jmeridth <jmeridth@gmail.com>
@jmeridth jmeridth self-assigned this Mar 3, 2026
Copilot AI review requested due to automatic review settings March 3, 2026 10:26
@jmeridth jmeridth requested a review from zkoppert as a code owner March 3, 2026 10:26
@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

Fixes GitHub App authentication failures when GH_APP_ID is provided as an integer by ensuring the App ID is passed as a string where required.

Changes:

  • Convert gh_app_id to str before calling github3’s login_as_app_installation.
  • Strengthen and extend unit tests to assert exact login_as_app_installation call arguments, including an integer app_id case.
  • Ignore local Claude config artifacts via .gitignore.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
auth.py Coerces gh_app_id to str when authenticating as a GitHub App installation.
test_auth.py Tightens mock assertions and adds a regression test for integer app_id inputs.
.gitignore Adds ignore rule for .claude local files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zkoppert zkoppert merged commit 74c51e7 into main Mar 3, 2026
39 checks passed
@zkoppert zkoppert deleted the jm_fix_app_id branch March 3, 2026 22:17
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