Skip to content

fix(acp): accept https:// URIs in image content blocks#24772

Closed
truenorth-lj wants to merge 1 commit intoanomalyco:devfrom
truenorth-lj:fix-acp-image-https-uri
Closed

fix(acp): accept https:// URIs in image content blocks#24772
truenorth-lj wants to merge 1 commit intoanomalyco:devfrom
truenorth-lj:fix-acp-image-https-uri

Conversation

@truenorth-lj
Copy link
Copy Markdown

Problem

packages/opencode/src/acp/agent.ts:1394 reads:

} else if (part.uri && part.uri.startsWith("http:")) {

This prefix check matches http://... URLs but not https://... URLs ("http:" is a literal 5-character prefix; "https://..." does not start with that exact substring because position 4 is s not :).

Every other URL check in the same codebase uses both prefixes:

File Pattern
packages/opencode/src/session/instruction.ts:146,168 startsWith("https://") || startsWith("http://")
packages/opencode/src/cli/cmd/import.ts:98 startsWith("http://") || startsWith("https://")
packages/opencode/src/tool/webfetch.ts:23 !startsWith("http://") && !startsWith("https://")
packages/opencode/src/config/config.ts:1270 startsWith("http://") || startsWith("https://")

Only acp/agent.ts:1394 is missing https://. It looks like a typo (probably meant to write "http://" but the second / was dropped).

Reproducer

Send an ACP session/prompt request with an image content block whose uri is https://:

{
  "type": "image",
  "uri": "https://storage.googleapis.com/bucket/img.png",
  "mimeType": "image/png"
}

Expected: image part is forwarded to the LLM provider as a file part.
Actual: the case falls through (no parts.push), and the image is silently dropped from the prompt — no error, no warning.

This is the most likely path for any ACP client doing two-stage uploads (e.g. signing a GCS or S3 URL and sending the URL rather than inlining base64), because cloud-storage signed URLs are always https://.

Fix

One-line: align with the other 5 URL checks in this codebase by accepting both http:// and https:// prefixes explicitly.

-          } else if (part.uri && part.uri.startsWith("http:")) {
+          } else if (part.uri && (part.uri.startsWith("http://") || part.uri.startsWith("https://"))) {

Tests

I haven't added a unit test in this PR because I couldn't find an existing test for the surrounding case "image" block that I could extend. Happy to add one if you'd like — point me at the right test file pattern.

Out of scope

This is a typo fix — no behavior change for http:// URIs or for inline-data blocks. No new dependencies.

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.
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Apr 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 28, 2026
@github-actions github-actions Bot closed this Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant