-
Stefy Lanza (nextime / spora ) authored
Fixes a NameError shipped in 0.4.94: `name 'model_key' is not defined` on every /v1/images/edits request. Replacing that endpoint's load block with the shared _pipeline_for_task call removed the line defining model_key, while a line further down still used it to look up the model's config. The inpaint endpoint got its replacement definition; this one did not. Editing was broken from the moment it was deployed, and a client reported it from production. 187 tests covered this code and none of them caught it, because every one read the source as text -- is this guard present, does this call precede that one. A structural test cannot see an undefined name on the first line of the request path. That is a flaw in how the work was tested, not bad luck. So the endpoints are now executed. tests/test_image_edit_endpoints_actually_run.py calls create_image_edit and create_image_inpaint with their collaborators stubbed -- the manager, image decode, the response writer, the pipeline -- so the whole body between the request arriving and the pipeline being called actually runs. Checked the way a regression test has to be: with the bug reintroduced it fails with the production message verbatim, and passes with the fix. One that passed either way would have been worth nothing. The tests assert what the body is for, not just that it returns: that the SOURCE IMAGE arrives at the pipeline at the size requested, that an omitted size keeps the photo's aspect instead of squaring it, that the mask matches the image's shape, that a malformed size is a 400 from the endpoint rather than a 500 from inside it, and that a model's prompt_prefix survives every layer in between. Also noted for whoever reaches for a linter next: a stdlib undefined-name scan was tried first and would NOT have caught this one, since it cannot tell a function-local assignment from a module-level name. Real scope analysis means pyflakes, which is not a dependency here. Full suite 4558 passed with the same 15 pre-existing failures as 0.4.91 (diff empty). Co-Authored-By:
Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S8LAP3ueNzQJtwzhgVbq66
b647515b