fix(acp): accept https:// URIs in image content blocks#24816
Open
truenorth-lj wants to merge 1 commit intoanomalyco:devfrom
Open
fix(acp): accept https:// URIs in image content blocks#24816truenorth-lj wants to merge 1 commit intoanomalyco:devfrom
truenorth-lj wants to merge 1 commit intoanomalyco:devfrom
Conversation
The previous prefix check `startsWith("http:")` only matches `http://...`
URLs and silently drops `https://...` URLs. Every other URL check in this
codebase (instruction.ts, import.ts, webfetch.ts, config.ts) checks both
prefixes — this appears to be a typo.
The bug surfaces when an ACP client sends an image content block with a
two-stage upload URL (e.g. a GCS signed URL), which is always https. The
case falls through and the image is silently dropped from the prompt.
Repro:
Send ACP session/prompt with content:
{ type: "image", uri: "https://example.com/x.png", mimeType: "image/png" }
Expected: image part forwarded to LLM provider
Actual: image silently dropped (no error, no parts.push)
Fix: align with the other 5 URL checks in this codebase by accepting both
http:// and https:// prefixes explicitly.
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.
Issue for this PR
Closes #24815
Type of change
What does this PR do?
packages/opencode/src/acp/agent.ts:1394previously read:That prefix only matches
http://—https://fails the check (the 5th char iss, not:), so the entirecase "image":branch falls through andparts.pushnever runs. The image is silently dropped from the prompt with no error.This breaks ACP clients doing two-stage uploads (sign a GCS / S3 URL, pass the
https://URL via the ACPimageblock instead of inlining base64).This PR aligns the check with the rest of the codebase, where every other URL test uses both prefixes:
packages/opencode/src/session/instruction.ts:146,168startsWith("https://") || startsWith("http://")packages/opencode/src/cli/cmd/import.ts:98startsWith("http://") || startsWith("https://")packages/opencode/src/tool/webfetch.ts:23!startsWith("http://") && !startsWith("https://")packages/opencode/src/config/config.ts:1270startsWith("http://") || startsWith("https://")The fix is one line:
This matches what the surrounding code clearly intends —
parseUri(part.uri)two lines above already accepts both schemes — and brings this branch in line with the conventions used everywhere else in the repo.How did you verify your code works?
Reproduced the bug locally before the fix:
session/promptwith{ "type": "image", "uri": "https://example.com/x.png", "mimeType": "image/png" }.partsarray passed downstream — image part is missing.urlset to thehttps://URL.The change is the most narrowly scoped possible (one boolean expression), and there are no tests for the surrounding
case "image":switch in this file, so I haven't added one in this PR — happy to add one if you point me at the test file pattern you'd want.Screenshots / recordings
N/A (no UI change).
Checklist