fix(vertex): throw clear error when document blocks use URL sources#1042
Open
Zelys-DFKH wants to merge 1 commit into
Open
fix(vertex): throw clear error when document blocks use URL sources#1042Zelys-DFKH wants to merge 1 commit into
Zelys-DFKH wants to merge 1 commit into
Conversation
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.
Fixes #1038
When Vertex AI rejects a document block with a URL source, the error it returns references
image.source.base64.data, a field that has nothing to do with document blocks. I spent a while chasing that before realizing the issue was the source type, not the data format. Not a fun detour.This adds a pre-flight check in
buildRequest()that catches URL sources before the request goes out and throws a clearAnthropicErrorwith the base64 workaround in the message. I also covered the nested case: a document URL source insidetool_result.content[]hits the same misleading error path, so anyone who fixed the top-level issue would run straight into it next.What changed:
packages/vertex-sdk/src/client.ts:validateNoDocumentUrlSources()called in theMODEL_ENDPOINTSblock, with acheckBlock()helper that handles both the top-level and nested cases.packages/vertex-sdk/tests/client.test.ts: Three new tests covering URL source at top level (throws), URL source inside a tool result (throws), and base64/text sources (pass).Prettier and ESLint pass. All 11 tests pass.
Good codebase to dig through. The
buildRequest()override made the right place to add the check immediately obvious. Thanks for keeping it so clean.