fix coercion service not selecting correct rule#2660
fix coercion service not selecting correct rule#2660ProgrammerIn-wonderland merged 1 commit intoHeyPuter:mainfrom
Conversation
|
@KernelDeimos does this look correct? |
|
This does look correct. How do we test this? (i.e. through which driver/feature was the problem observed and what steps were taken to produce it?) |
original issue came out of the gemini image generation driver causing this error when requesting a 2K quality image with flash-image-3.1: i traced the issue to secureAxiosRequest in securehttp.js. i wasn't able to reproduce the crash locally, but later realized that it shouldn't have went this way at all, as the gemini service was returning a string:url:data, while secureAxiosRequest was only supposed to be for string:url:web types. puter/src/backend/src/services/drivers/CoercionService.js Lines 162 to 175 in e28a5b0 putting a few console logs around this spot i noticed that it was using the coercion, resulting in odd behavior on smaller images too, such as content-type being "undefined" before the fix: you can test this on live puter.com right now: puter.ai.txt2img('generate an image', options= {
ratio: {"w": 1, "h": 1},
quality: "1K",
model: "google:google/gemini-3.1-flash-image-preview",
})going into network tab, the /call will have content-type: undefined. puter.ai.txt2img('generate an image', options= {
ratio: {"w": 1, "h": 1},
quality: "2K",
model: "google:google/gemini-3.1-flash-image-preview",
})and this will result in the error mentioned above |


currently coerce method always returns a value even when no coercion is found. this causes a "string:url:data" type result to run through a "string:url:web -> stream" coercion instead of the intended "string:url:data -> stream", resulting in issues such as undefined content_type and passing a base64 data url into the web url processing logic.
changed the method to return undefined in case no valid coercion was found and to allow it to try others.
side note: TypeSpec.equals() only checks the base value ($) ignoring content_type. this means a content_type: video result can get routed through a content_type: image rule. this doesn't break anything right now as they're almost the same, but something to keep in mind.
puter/src/backend/src/services/drivers/meta/Construct.js
Lines 156 to 168 in 8767280