Skip to content

fix(vertex): throw clear error when document blocks use URL sources#1042

Open
Zelys-DFKH wants to merge 1 commit into
anthropics:mainfrom
Zelys-DFKH:fix/vertex-document-url-source
Open

fix(vertex): throw clear error when document blocks use URL sources#1042
Zelys-DFKH wants to merge 1 commit into
anthropics:mainfrom
Zelys-DFKH:fix/vertex-document-url-source

Conversation

@Zelys-DFKH
Copy link
Copy Markdown

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 clear AnthropicError with the base64 workaround in the message. I also covered the nested case: a document URL source inside tool_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 the MODEL_ENDPOINTS block, with a checkBlock() 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.

@Zelys-DFKH Zelys-DFKH requested a review from a team as a code owner May 13, 2026 19:02
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.

Vertex AI: document URL sources rejected with incorrect error path

1 participant