Support hosted Dependabot through REST-only GitHub API access by nodeselector · Pull Request #94 · github/gh-actions-lock · GitHub
Skip to content

Support hosted Dependabot through REST-only GitHub API access - #94

Merged
nodeselector merged 6 commits into
mainfrom
nodeselector-dependabot-rest-fallback
Jul 27, 2026
Merged

nodeselector merged 6 commits into
mainfrom
nodeselector-dependabot-rest-fallback

Conversation

@nodeselector

@nodeselector nodeselector commented Jul 27, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Hosted Dependabot supplies a dummy GitHub token, while its proxy injects the real token only for GET and HEAD requests. gh-actions-lock used GraphQL POST requests during relock, so action resolution failed with 401 Bad credentials.

How

  • Use the private integration context GH_ACTIONS_LOCK_DEPENDABOT_PROXY=1 to select REST-only mode at client startup. This avoids coupling behavior to the dummy token value without adding a CLI flag or documented user-facing feature.
  • Resolve action files, peel annotated tags, and check branch reachability with REST GET requests without first attempting GraphQL.
  • Reuse the existing REST fallback for public and proxy-authenticated private repositories.
  • Preserve GraphQL batching and authentication-failure fallback for normal execution.

The fallback remains fail-closed: inaccessible repositories and unreachable refs still return errors. This does not require allowing authenticated POST requests through the Dependabot proxy.

Testing

  • go test -race -count=1 ./...
  • go vet ./...
  • make fmt-check
  • make build && /opt/homebrew/opt/ruby/bin/ruby test/integration/run.rb dependabot_proxy_rest_only

The integration scenario runs the compiled binary against a private-repository stub with REST responses only. Any GraphQL POST has no matching handler and fails the scenario.

A new gh-actions-lock release is required, and the Dependabot caller must set the private execution-context variable.

Copilot AI review requested due to automatic review settings July 27, 2026 20:37
@nodeselector
nodeselector requested a review from a team as a code owner July 27, 2026 20:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds REST-only resolution for hosted Dependabot while retaining GraphQL behavior for normal tokens.

Changes:

  • Detects Dependabot’s proxy token.
  • Routes resolution, tag peeling, and reachability through REST.
  • Expands fallback tests and eligibility checks.
Show a summary per file
File Description
internal/ghapi/client.go Detects REST-only mode.
internal/ghapi/rest_fallback.go Adds repository-level fallback eligibility.
internal/ghapi/graphql_action_files.go Routes action resolution through REST.
internal/ghapi/graphql_peel.go Routes tag peeling through REST.
internal/ghapi/graphql_reachability.go Routes reachability checks through REST.
internal/ghapi/rest_fallback_test.go Consolidates and expands fallback tests.
internal/ghapi/anon_fallback_test.go Removes superseded tests.

Review details

Tip

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

  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread internal/ghapi/graphql_peel.go
@nodeselector
nodeselector merged commit 9e7f347 into main Jul 27, 2026
11 checks passed
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.

2 participants