Repository navigation
fix(codearts): inline remote image URLs as base64 data URLs - #548
Merged
caigee-cmd merged 2 commits intoNov 20, 2026
Merged
Conversation
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.
This was referenced Nov 20, 2026
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.
Summary
data:URLs for image parts. Remote http(s) references fail upstream withInferHub.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.inlineMessageImagesnow runs at the top ofdoChat: every remote image URL in the request is downloaded once through the account's proxy-aware client, rewritten in place to a base64data:URL, and cached briefly (16 entries / 64 MB / 10 min) so replayed conversation turns do not re-fetch the same attachment.Content-Type, thenhttp.DetectContentTypesniffing, then the URL extension, so mislabeled object storage still yields a usable type.400 invalid_requestnaming 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/upstreamContentstay pure and byte-for-byte unchanged for text-only requests.Test plan
go test ./internal/providers/codearts/— new tests inimages_test.gocover: 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=1go vet ./...,gofmt -lcleanInferHub.ModelArts.81001.400now returns a correct vision answer fromkimi-k3.1-pro; second identical request is served from cache; text-only chat unchanged.