Skip to content

fix(gallery): answer 400 for a missing or invalid image on the image-edit routes (#6818) - #6819

Open
dxrpl wants to merge 2 commits into
odysseus-dev:devfrom
dxrpl:fix/6818-image-routes-bad-input
Open

dxrpl wants to merge 2 commits into
odysseus-dev:devfrom
dxrpl:fix/6818-image-routes-bad-input

Conversation

@dxrpl

@dxrpl dxrpl commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Summary

sharpen, remove-bg, denoise, upscale-local and enhance-face decoded the client's image with a bare base64.b64decode + Image.open, so a missing, malformed or non-image image ended in an unhandled exception and a 500. They now use the existing _b64_to_pil_image() helper, which harmonize, inpaint and mask already use, so they answer 400 Missing image / 400 Invalid image. The existing 400 No image provided checks in denoise, upscale-local and enhance-face stay as they were. Valid images are processed as before.

Target branch

  • This PR targets the correct integration branch: lab in the private maintainer-preview repository, or dev in the public repository. main remains release-curated.

Linked Issue

Fixes #6818

Type of Change

  • Bug fix (non-breaking — fixes a confirmed issue)
  • New feature (non-breaking — adds new behaviour)
  • Breaking change (changes or removes existing behaviour)
  • Refactor / cleanup (behaviour unchanged)
  • Documentation only
  • CI / tooling / configuration

Checklist

  • I searched open issues and open PRs — this is not a duplicate.
  • This PR targets the correct integration branch (lab in maintainer-preview; dev in the public repository)
  • My changes are limited to the scope described above — no unrelated refactors or whitespace changes mixed in.
  • I actually ran the app (docker compose up or uvicorn app:app) and verified the change works end-to-end. Type-checks and unit tests are not enough.
  • I did not run the app/runtime validation and stated that gap in How to Test. Leave this unchecked when the app-run box above is checked.

How to Test

I ran the branch natively (uvicorn app:app, scratch data dir), logged in as admin, and POSTed {}, {"image":"!!notb64"} and {"image":"aGVsbG8="} to each of the five routes. On dev these gave 500 (12 of the 15 requests; the other 3 were the existing No image provided 400). On this branch all 15 give 400. I did not run the editor UI or a real image through Real-ESRGAN/GFPGAN, because those packages are not installed here. The new tests/test_gallery_image_bad_input.py fails on dev (12 failures) and passes with the change, together with the existing gallery tests.

To check by hand:

  1. Start the app and log in.
  2. curl -b cj -X POST -H 'content-type: application/json' -d '{"image":"!!notb64"}' localhost:7000/api/image/sharpen (repeat for remove-bg, denoise, upscale-local, enhance-face).
  3. Each should return 400 {"detail":"Invalid image"}, not a 500.

Visual / UI changes — REQUIRED if you touched anything that renders

No visual change: the edit only fixes variable scoping so the existing timeout message is reachable. No markup, CSS or styling was touched.

  • Screenshot or short clip: not applicable, see above.
  • I am not an LLM agent submitting a bulk PR.

Screenshots / clips

The reply bubble after the 120 s timeout, with the fix applied:

timeout-bubble

@github-actions github-actions Bot added the ready for review Description complete — ready for maintainer review label Oct 24, 2026
@dxrpl
dxrpl force-pushed the fix/6818-image-routes-bad-input branch from d978c60 to 6b284d2 Compare October 28, 2026 17:27

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review Description complete — ready for maintainer review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image edit routes (sharpen, remove-bg, denoise, upscale-local, enhance-face) return 500 for a missing or invalid image

1 participant