OpenAI's images edit takes `markup`, a transparent PNG laid over the
first image to steer the edit (JSON image_url, or a multipart file part;
never beside a mask). magpie read only the mask: a JSON markup stopped in
drawing.Extra, a multipart one was dropped, and neither the ChatGPT
backend's JSON edit nor the plain multipart edit carried it, so an edit
with a markup came back 200 with the layer left out (#5364, kongjianguan,
with the probe and the three places).
drawing has a Markup beside Mask, read from JSON (markup.image_url) and
from a multipart `markup` part, and sent where the mask is: as
{"image_url": data URL} on the ChatGPT/SenseNova JSON edit and as its own
part on the multipart edit. A markup that can't be read, or one sent with
a mask, is a 400 before anything is asked. OpenRouter, Volcengine Ark and
DashScope, which turn a mask away, turn a markup away by name too.
Patch from ggbdpq (mbox sha256 b591c6ad499789c5, matches the issue).
Changed in review:
- "markup" joins drawingRead, so it no longer also rides Extra; on Ark
the raw field went out as an Ark field.
- Ark and DashScope refuse a markup as they refuse a mask; the patch
refused it on OpenRouter only.
- A mask with a markup is a 400 (OpenAI's docs: "Cannot be combined
with mask").
- Tests rewritten: the patch's broken-markup test posted to a server
with no "art" provider, so it would have been a 400 for the unknown
model with or without the fix; the Codex test kept its upstream in a
package global. They now check the bytes that reach the vendor, the
multipart-in case, the mask clash and the three refusals.
Run on mote (-tags nogui, the package's TestMain sandbox):
- TestCodexEditSendsTheMarkup, TestEditSendsTheMarkup/{json,multipart},
TestEditWithAMarkupItCantSendIsRefused/{not base64,beside a mask},
TestMarkupRefusedWhereNoLayerIsTaken: ok.
- Broken by hand: draw.go, draw_dashscope.go, draw_volcengine.go back to
cff530079 (Markup field kept so the tests build): all four FAIL ("the
ChatGPT edit's markup is \"\"", "kept as an extra field too", "the
markup layer never reached the vendor whole", "not base64: 200, want
400", "beside a mask: 200", "Ark: <nil>", "DashScope: <nil>",
"OpenRouter: 502 ... want 400").
- -race -run 'Draw|Image|Edit|Ark|DashScope|OpenRouter|Markup|Mask|Volc|
Seedream|ModelScope|SenseNova' ./internal/gateway: ok 108s.
- go vet -tags nogui, GOOS=linux go vet -tags nogui, GOOS=windows go vet
of ./internal/gateway: clean. gofmt -l: clean.
Not tried: a real ChatGPT account's gpt-image edit with a markup (none
here), so whether that backend applies the field, or refuses it, is
unknown; OpenAI's public docs list markup for GPT Image 2.5. Not
changed: routes that drop a mask today (Grok, ModelScope, chat-model and
Gemini draws, WorkBuddy) drop a markup the same way. The full suite is
run after the push.
Reported-by: kongjianguan
Co-authored-by: ggbdpq <ggbdpq@gmail.com>