Skip to content

fix: handle GitHub OIDC format and error handling#37889

Open
chAwater wants to merge 3 commits into
anomalyco:devfrom
chAwater:fix-37823
Open

fix: handle GitHub OIDC format and error handling#37889
chAwater wants to merge 3 commits into
anomalyco:devfrom
chAwater:fix-37823

Conversation

@chAwater

Copy link
Copy Markdown

Issue for this PR

Closes #37823

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The GitHub OIDC tokens changed from repo:octocat/my-repo:ref:refs/heads/main to repo:octocat@123456/my-repo@456789:ref:refs/heads/main (according to the GitHub changelog), breaking the exchange_github_app_token endpoint and causing a cryptic failure chain in the GitHub Action log.

> Run opencode github run
Failed to parse JSON
Creating comment...
Error: Unexpected error

undefined is not an object (evaluating 'p.rest')

The root cause is a three-link chain (detailed analysis in the issue #37823):

  1. api.ts — owner/repo parsed incorrectly from new sub format
    New format repo:octocat@123456/my-repo@456789:ref:… was split as-is, producing octocat@123456 / my-repo@456789, which fails the installation lookup.
  2. api.ts — uncaught installation lookup error returns non-JSON 500
    The failed getRepoInstallation call throws through Hono without a catch, so the client receives an HTML/text error page.
  3. github.handler.ts — client assumes JSON response, masks the real error
    response.json() fails on the text body → Failed to parse JSON. Then the catch block calls createComment with an uninitialized octoRestundefined is not an object (evaluating 'p.rest'), which buries the real cause.

This PR fixes the parsing of new OIDC tokens and adding error handling to expose the real error message.

How did you verify your code works?

The api.ts cannot be tested end-to-end before deployment.
I only tested the error handling part using a test repo with test workflow: GitHub Actions logs

Screenshots / recordings

None

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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.

GitHub action fails on repos created after 2026-07-15 (new OIDC sub format)

1 participant