fix: use Anthropic SDK for comment classification instead of hardcoded API URL#1154
Open
the-real-mathew-moon wants to merge 2 commits intoanthropics:mainfrom
Open
Conversation
…ification The `classifyComments()` function in `post-buffered-inline-comments.ts` was using a raw `fetch()` call to a hardcoded `https://api.anthropic.com/v1/messages` URL. This ignores `ANTHROPIC_BASE_URL`, which breaks users routing traffic through a proxy or custom gateway. Replace the raw fetch with the official `@anthropic-ai/sdk` client, which automatically reads `ANTHROPIC_API_KEY` and `ANTHROPIC_BASE_URL` from the environment. Also pass `ANTHROPIC_BASE_URL` into the post-buffered-inline-comments step in `action.yml` so the env var is available at runtime. Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Code <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fetch()call to hardcodedhttps://api.anthropic.com/v1/messagesinpost-buffered-inline-comments.tswith the official@anthropic-ai/sdkclientANTHROPIC_API_KEYandANTHROPIC_BASE_URLenvironment variables, fixing the issue for users routing traffic through a proxy or custom gatewayANTHROPIC_BASE_URLenv var to the post-buffered-inline-comments step inaction.ymlMotivation
The
classifyComments()function used a hardcodedhttps://api.anthropic.com/v1/messagesURL via rawfetch(), bypassingANTHROPIC_BASE_URL. Users who set this env var to route traffic through an LLM gateway or proxy found that the comment classification step always hitapi.anthropic.comdirectly.Changes
src/entrypoints/post-buffered-inline-comments.tsfetch()withnew Anthropic().messages.create()action.ymlANTHROPIC_BASE_URLto the post-buffered-inline-comments steppackage.json/bun.lock@anthropic-ai/sdkdependencyNote on
src/github/token.tsThe other hardcoded
api.anthropic.comusage intoken.ts(/api/github/github-app-token-exchange) is a proprietary Anthropic infrastructure endpoint for OIDC token exchange — not a standard Messages API call. It cannot be replaced with an SDK call, and making it respectANTHROPIC_BASE_URLcould break functionality (e.g., Bedrock/Vertex proxies wouldn't have this endpoint).Test plan
bun run typecheckpassesbun run format:checkpassesbun test— all 653 tests passGenerated with Claude Code