Repository navigation
fix(capture): validate the Vertex region and model id before captioning - #7533
Merged
Merged
Conversation
Vision captioning passes the region and model id to the Google SDK, which builds the request host from the region and the request path from the model id. A region that is not a plain Google Cloud region name, or a model id with URL delimiters, now skips captioning with a warning instead of building a request. Every real region (including "global") and model id still works. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Vertex endpoint paths in domain-scoped projects contain a colon (projects/example.com:proj/...). The colon cannot change the request host, so allow it inside a segment. Leading slashes, empty segments, percent signs, query and fragment delimiters stay rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Verdict: APPROVE · 0 blocker · 0 important · 0 nits · head 9bca2d9
I checked this against @google/genai 1.52.0. The SDK builds the Vertex host as https://${location}-aiplatform.googleapis.com/ (or the fixed global, us and eu hosts) and adds the model path by string concatenation. A location limited to [a-z][a-z0-9-]* therefore can't change the host. PROJECT_ENV_KEYS doesn't include GOOGLE_VERTEX_BASE_URL or GOOGLE_GEMINI_BASE_URL, so a project .env can't move the request somewhere else either. The model check adds % rejection on top of the SDK's own ../?/& rejection, which covers WHATWG %2e%2e dot segments.
— Genesis V2
Merged
3 of 4 tasks
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.
What changed
hyperframes capturecaptions images with Vertex AI. It reads the region (HYPERFRAMES_VERTEX_LOCATION) and the model id from the environment, which can come from a project's.envfile. The Google SDK builds the request host from the region and the request path from the model id.us-central1,europe-west4,me-central2), theusandeumulti-regions, andglobal. A region can no longer contain a.,/,@,:or#, so the request host always stays ongoogleapis.com./-separated segments. Each segment starts with a letter or digit and contains only letters, digits,_,.,-,@and:. This rejects%(which can encode..),?,#, a leading/and empty segments. A colon is allowed inside a segment because Vertex endpoint paths in domain-scoped projects contain one (projects/example.com:proj/...); it cannot change the request host.Every real region and Google model id behaves exactly as before, including the defaults (
us-central1,gemini-2.5-flash,gemini-3.1-flash-lite-preview). OpenRouter model ids are not checked, because they go in the request body rather than the URL.Not done
hyperframes snapshot --describealso readsHYPERFRAMES_GEMINI_MODEL, and it is not checked here. That path uses a Gemini API key on a fixed host, and the SDK already rejects..,?and&in model ids.HYPERFRAMES_VERTEX_PROJECT_IDalso goes into the request path and is not checked. It cannot change the request host.Testing
packages/cli/src/capture/contentExtractor.test.ts: 10 rejection cases (5 regions, 5 model ids) that fail without the fix, plus accepted regions (global,us,eu,europe-west4) and accepted model ids (a bare id,publisher/model, a Model Garden id with@version, and a domain-scoped endpoint path). All 46 tests in the file pass.🤖 Generated with Claude Code