Skip to content

fix(codearts): inline remote image URLs as base64 data URLs - #548

Merged
caigee-cmd merged 2 commits into
caigee-cmd:mainfrom
ATP-01:fix/codearts-inline-remote-images
Nov 20, 2026
Merged

caigee-cmd merged 2 commits into
caigee-cmd:mainfrom
ATP-01:fix/codearts-inline-remote-images

Conversation

@ATP-01

@ATP-01 ATP-01 commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The CodeArts inference endpoint only accepts inline data: URLs for image parts. Remote http(s) references fail upstream with InferHub.ModelArts.81001.400 "unsupported image url", so any client that sends hosted attachment links — e.g. a Qoder / WorkBuddy custom endpoint pointing at this gateway, which transmits signed OSS URLs for pasted images — could never use vision models.
  • inlineMessageImages now runs at the top of doChat: every remote image URL in the request is downloaded once through the account's proxy-aware client, rewritten in place to a base64 data: URL, and cached briefly (16 entries / 64 MB / 10 min) so replayed conversation turns do not re-fetch the same attachment.
  • MIME type resolution prefers the served Content-Type, then http.DetectContentType sniffing, then the URL extension, so mislabeled object storage still yields a usable type.
  • Fetch failures surface as a 400 invalid_request naming the origin host (expired signature, 404, oversized payload >20 MB), instead of the previous opaque upstream error.
  • data: URLs and non-image messages pass through untouched; buildChatBody / upstreamContent stay pure and byte-for-byte unchanged for text-only requests.

Test plan

  • go test ./internal/providers/codearts/ — new tests in images_test.go cover: data: passthrough, download+inline, MIME sniffing without Content-Type, cache hit (origin hit exactly once), 404 → clean error, in-place rewrite of message parts.
  • go test ./internal/app -run 'TestImportConstraints|TestDutyBoundaries' -count=1
  • go vet ./..., gofmt -l clean
  • End-to-end on a live deployment: a real signed OSS image URL that previously failed with InferHub.ModelArts.81001.400 now returns a correct vision answer from kimi-k3.1-pro; second identical request is served from cache; text-only chat unchanged.
  • CI green

Cao Yuhao and others added 2 commits November 19, 2026 18:51
The CodeArts inference endpoint only accepts inline data: URLs for image
parts; remote http(s) references fail with InferHub.ModelArts.81001.400
"unsupported image url". Hosted-agent clients (Qoder / WorkBuddy custom
endpoints) legitimately send signed object-storage links for attachments,
so those requests could never reach the model.

Download each remote image once through the account's proxy-aware client,
rewrite the part in place to a data: URL, and cache the result briefly so
replayed conversation turns do not re-fetch the same attachment. MIME type
comes from Content-Type, content sniffing, or the URL extension. Fetch
failures surface as a 400 invalid_request that names the origin host.
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.

2 participants