Skip to content

test-companion: fix signing in as the GitHub App, and say why it fails - #95

Open
naimish-browse wants to merge 2 commits into
browserstack:masterfrom
naimish-browse:test-companion-app-auth-errors
Open

naimish-browse wants to merge 2 commits into
browserstack:masterfrom
naimish-browse:test-companion-app-auth-errors

Conversation

@naimish-browse

@naimish-browse naimish-browse commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Signing in as the GitHub App never worked, and the Action hid why.

The bug. The Action sent the App's signed login (a JWT) through gh. gh sends it as Authorization: token …, but GitHub accepts an App's JWT only as Authorization: Bearer …. So every sign-in failed with A JSON web token could not be decoded (HTTP 401), and the Action quietly fell back to github-actions[bot], even with the correct App ID and key.

Checked against the real App with the same key and App ID: through gh, 401; with Bearer, 200 and the installation found.

What changes

  • The two calls made as the App (find the installation, get the short-lived token) now use fetch with Bearer. Everything after that uses the installation token through gh, as before.
  • Failures say why. Only a 404 is reported as "not installed", as a notice. Any other failure is a warning with GitHub's own reason, e.g. Bad credentials (HTTP 401), and says to check app-id and app-private-key. A failed token request and the two previously silent fallbacks now explain themselves too.
  • Uses GITHUB_API_URL, so GitHub Enterprise Server works too.

The logged reason is GitHub's response message only, never the JWT or a token.

Tests: 9 new for the App calls and messages; all 700 pass.

🤖 Generated with Claude Code

Any failure to look up the App's installation was reported as "the GitHub
App is not installed on this repository", hiding GitHub's real answer.
A wrong App ID or a key from another App looked exactly like a missing
installation.

Now only a 404 is reported as "not installed". Any other failure is a
warning that carries GitHub's own reason, e.g. "Bad credentials
(HTTP 401)", and says which inputs to check. A failed token request
also carries GitHub's reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@naimish-browse
naimish-browse requested a review from a team as a code owner November 11, 2026 13:30
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Pre-merge checks: Passed 1 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Title check Pending This assessment has not completed. The check will be retried on the next pre-merge check run.
Passed Passed checks: 1 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

gh sends its token as "Authorization: token ...", and GitHub accepts an
App's JWT only as "Authorization: Bearer ...". So every App sign-in
failed with "A JSON web token could not be decoded (HTTP 401)" and the
Action fell back to github-actions[bot], even with the right App ID and
key. Checked against the real App: through gh, 401; with Bearer, 200.

The two calls made as the App (find the installation, get the token)
now use fetch with Bearer. Everything after uses the installation token
through gh as before. The two remaining silent fallbacks now say why.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@naimish-browse naimish-browse changed the title test-companion: say why signing in as the GitHub App failed test-companion: fix signing in as the GitHub App, and say why it fails Nov 11, 2026
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.

1 participant