Skip to content

fix(agents): prevent /v1beta duplication in Gemini PDF URL#34369

Merged
vincentkoc merged 1 commit intoopenclaw:mainfrom
0xsline:fix/gemini-pdf-v1beta-url-duplication
Mar 10, 2026
Merged

fix(agents): prevent /v1beta duplication in Gemini PDF URL#34369
vincentkoc merged 1 commit intoopenclaw:mainfrom
0xsline:fix/gemini-pdf-v1beta-url-duplication

Conversation

@0xsline
Copy link
Copy Markdown
Contributor

@0xsline 0xsline commented Mar 4, 2026

Summary

  • Strip trailing /v1beta from baseUrl in geminiAnalyzePdf before appending the version segment, preventing /v1beta/v1beta/models/… URLs that cause 404 errors from the Gemini API.
  • Add regression test asserting no /v1beta duplication when baseUrl already includes the version prefix.

Closes #34312

Test plan

  • Existing 50 PDF tool tests pass
  • New regression test: geminiAnalyzePdf does not duplicate /v1beta when baseUrl already includes it
  • Manual: configure pdfModel as google/gemini-3.1-pro-preview with a baseUrl ending in /v1beta, invoke PDF tool via subagent path, verify 200 response

🤖 Generated with Claude Code

Strip trailing /v1beta from baseUrl before appending the version
segment, so callers that already include /v1beta in their base URL
(e.g. subagent-registry) no longer produce /v1beta/v1beta/models/…
which results in a 404 from the Gemini API.

Closes openclaw#34312

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 4, 2026

Greptile Summary

This PR fixes a URL-construction bug in geminiAnalyzePdf where passing a baseUrl that already ends in /v1beta (a common pattern for OpenAI-compatible proxy configurations) caused the request path to become /v1beta/v1beta/models/…, resulting in 404 errors from the Gemini API. The fix is a single additional .replace(/\/v1beta$/, "") call chained after the existing trailing-slash normalisation, applied before the hardcoded /v1beta segment is appended. A targeted regression test is included.

  • Fix: baseUrl normalisation in geminiAnalyzePdf now strips a trailing /v1beta segment before re-appending it, eliminating the duplication.
  • Correctness: The order of operations is right — trailing slashes are removed first, so …/v1beta/ is correctly handled before the version-strip regex runs.
  • Test coverage: The new test passes a baseUrl ending in /v1beta, captures the URL that was passed to fetch, and asserts both that /v1beta/models/ is present and that /v1beta/v1beta is absent.
  • Scope: Only /v1beta is handled; other potential version strings (/v1, /v1alpha) are not normalised, but that is outside the scope of this targeted fix.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, well-tested bug fix with no side effects on other code paths.
  • The change is a single additional chained .replace() call that only affects geminiAnalyzePdf. The logic is correct, the regex is precise, existing tests continue to pass, and a dedicated regression test is included. There is no risk of regressions outside this function.
  • No files require special attention.

Last reviewed commit: 8f697ad

@openclaw-barnacle openclaw-barnacle bot added agents Agent runtime and tooling size: XS labels Mar 4, 2026
@vincentkoc vincentkoc self-assigned this Mar 10, 2026
@vincentkoc vincentkoc merged commit bfeea5d into openclaw:main Mar 10, 2026
31 checks passed
frankekn pushed a commit to MoerAI/openclaw that referenced this pull request Mar 11, 2026
…34369)

Strip trailing /v1beta from baseUrl before appending the version
segment, so callers that already include /v1beta in their base URL
(e.g. subagent-registry) no longer produce /v1beta/v1beta/models/…
which results in a 404 from the Gemini API.

Closes openclaw#34312

Co-authored-by: Claude Opus 4.6 <[email protected]>
frankekn pushed a commit to Effet/openclaw that referenced this pull request Mar 11, 2026
…34369)

Strip trailing /v1beta from baseUrl before appending the version
segment, so callers that already include /v1beta in their base URL
(e.g. subagent-registry) no longer produce /v1beta/v1beta/models/…
which results in a 404 from the Gemini API.

Closes openclaw#34312

Co-authored-by: Claude Opus 4.6 <[email protected]>
frankekn pushed a commit to ImLukeF/openclaw that referenced this pull request Mar 11, 2026
…34369)

Strip trailing /v1beta from baseUrl before appending the version
segment, so callers that already include /v1beta in their base URL
(e.g. subagent-registry) no longer produce /v1beta/v1beta/models/…
which results in a 404 from the Gemini API.

Closes openclaw#34312

Co-authored-by: Claude Opus 4.6 <[email protected]>
Treedy2020 pushed a commit to Treedy2020/openclaw that referenced this pull request Mar 11, 2026
…34369)

Strip trailing /v1beta from baseUrl before appending the version
segment, so callers that already include /v1beta in their base URL
(e.g. subagent-registry) no longer produce /v1beta/v1beta/models/…
which results in a 404 from the Gemini API.

Closes openclaw#34312

Co-authored-by: Claude Opus 4.6 <[email protected]>
dhoman pushed a commit to dhoman/chrono-claw that referenced this pull request Mar 11, 2026
…34369)

Strip trailing /v1beta from baseUrl before appending the version
segment, so callers that already include /v1beta in their base URL
(e.g. subagent-registry) no longer produce /v1beta/v1beta/models/…
which results in a 404 from the Gemini API.

Closes openclaw#34312

Co-authored-by: Claude Opus 4.6 <[email protected]>
ahelpercn pushed a commit to ahelpercn/openclaw that referenced this pull request Mar 12, 2026
…34369)

Strip trailing /v1beta from baseUrl before appending the version
segment, so callers that already include /v1beta in their base URL
(e.g. subagent-registry) no longer produce /v1beta/v1beta/models/…
which results in a 404 from the Gemini API.

Closes openclaw#34312

Co-authored-by: Claude Opus 4.6 <[email protected]>
Ruijie-Ysp pushed a commit to Ruijie-Ysp/clawdbot that referenced this pull request Mar 12, 2026
…34369)

Strip trailing /v1beta from baseUrl before appending the version
segment, so callers that already include /v1beta in their base URL
(e.g. subagent-registry) no longer produce /v1beta/v1beta/models/…
which results in a 404 from the Gemini API.

Closes openclaw#34312

Co-authored-by: Claude Opus 4.6 <[email protected]>
leozhengliu-pixel pushed a commit to leozhengliu-pixel/openclaw that referenced this pull request Mar 13, 2026
…34369)

Strip trailing /v1beta from baseUrl before appending the version
segment, so callers that already include /v1beta in their base URL
(e.g. subagent-registry) no longer produce /v1beta/v1beta/models/…
which results in a 404 from the Gemini API.

Closes openclaw#34312

Co-authored-by: Claude Opus 4.6 <[email protected]>
Interstellar-code pushed a commit to Interstellar-code/operator1 that referenced this pull request Mar 16, 2026
…34369)

Strip trailing /v1beta from baseUrl before appending the version
segment, so callers that already include /v1beta in their base URL
(e.g. subagent-registry) no longer produce /v1beta/v1beta/models/…
which results in a 404 from the Gemini API.

Closes openclaw#34312

Co-authored-by: Claude Opus 4.6 <[email protected]>
(cherry picked from commit bfeea5d)
senw-developers pushed a commit to senw-developers/va-openclaw that referenced this pull request Mar 17, 2026
…34369)

Strip trailing /v1beta from baseUrl before appending the version
segment, so callers that already include /v1beta in their base URL
(e.g. subagent-registry) no longer produce /v1beta/v1beta/models/…
which results in a 404 from the Gemini API.

Closes openclaw#34312

Co-authored-by: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Gemini native PDF URL duplication (/v1beta/v1beta) in subagent-registry causes 404

2 participants