Nobody has started this yet — be first.
Business impact
GET /images/{id} is the API's own promise of what's downloadable: it returns a thumbnails dict whose keys become the size= values a client is supposed to pass to GET /images/{id}/thumbnail. Right now, for every single successfully processed image, that promise is broken for one of the three advertised sizes: the URL the API itself hands back either 422s (because the size name isn't one the download endpoint's validator recognizes) or, if a client instead asks for the size name it expects based on the public API contract, 404s (because no file was ever saved under that name). Either way, one third of every gallery/thumbnail grid built against this API silently breaks with a broken-image icon, and it will look for all the world like a client bug rather than a server-side contract violation -- which is exactly the kind of cross-team "it's not on my side" debugging loop that burns a day of two engineers' time before anyone thinks to grep both sides of the API.
Problem
app/processing.py's THUMBNAIL_SIZES dict -- which drives what the background pipeline actually generates and saves -- no longer has an entry named "large". app/schemas.py's ThumbnailSize enum -- which is what GET /images/{id}/thumbnail?size=...'s Query(...) parameter validates incoming requests against -- still only knows small, medium, large. The two are supposed to name the exact same three tiers and no longer do.
Current behavior
GET /images/{id} on a ready image advertises thumbnail keys {"medium", "small", "xlarge"} instead of {"small", "medium", "large"}, and requesting ?size=large -- a value the download endpoint's own validator still happily accepts -- returns 404 THUMBNAIL_NOT_FOUND even though the image is fully ready.
Expected behavior
The set of thumbnail sizes the background pipeline generates (processing.THUMBNAIL_SIZES's keys) and the set of sizes the download endpoint accepts (schemas.ThumbnailSize's values) must be the same three names. Every URL GET /images/{id} advertises in its thumbnails field must be successfully downloadable via GET /images/{id}/thumbnail?size=... using that exact name.
Steps to reproduce
cd fastapi/image_service && source .venv/bin/activate python3 - <<'PY' from fastapi.testclient import TestClient from app.dependencies import Settings from app.main import create_app import io from PIL import Image
img = Image.new("RGB", (300, 300), (255, 0, 0)) buf = io.BytesIO(); img.save(buf, format="PNG")
settings = Settings(upload_dir="/tmp/t06/u", database_url="sqlite:////tmp/t06/db.sqlite3") client = TestClient(create_app(settings)) image_id = client.post("/images", files={"file": ("a.png", buf.getvalue(), "image/png")}).json()["id"]
meta = client.get(f"/images/{image_id}").json() print("advertised thumbnail keys:", sorted(meta["thumbnails"].keys())) print("GET .../thumbnail?size=large ->", client.get(f"/images/{image_id}/thumbnail", params={"size": "large"}).status_code) PY
Why this matters
This is a two-file contract, not a single function: nothing in app/main.py needed to change for this to break, because run_thumbnail_pipeline correctly and generically builds record.thumbnails from whatever keys generate_thumbnails() (driven by THUMBNAIL_SIZES) happens to produce. The bug is entirely in the fact that two independently-maintained lists of "the three size names" (one in processing.py, one in schemas.py) drifted apart. Reading either file in isolation looks completely correct -- you only find this by comparing them.
Suggested approach
Compare THUMBNAIL_SIZES in app/processing.py against ThumbnailSize in app/schemas.py, name by name. Decide which file has the "wrong" name (one of them doesn't match the other two, and doesn't match the README's own endpoint table either) and fix that side -- not both, and not by adding a fourth name to paper over the mismatch.
Acceptance criteria
Verification
pytest practicetickets/test_ticket06_thumbnail_size_key_mismatch.py -v
Hints (0/2)
Try it without hints first — the reading is the exercise.
Working on this ticket
Work on a branch named for the ticket — that's what you'll submit.
Branch off your fork
$git checkout -b fix/thumbnail-size-key-mismatchFix it and commit
Meet every acceptance criterion, and add a test that would have caught this.
Push the branch
$git push -u origin fix/thumbnail-size-key-mismatchSubmit it below
Paste your fork URL and the branch name, with a short write-up of the root cause.
Questions
Ask about anything unclear in the ticket — the maintainer and anyone who has solved it can answer. Please don't post full solutions.
Sign in to ask a question or reply.
Sign indocker-compose.yml./app./testsuvicorn --reload/app/dataDockerfile.proddocker compose -f docker-compose.prod.yml up --build -dWithout Docker:
cd fastapi/image_service
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements-dev.txt
cp .env.example .env # optional, defaults work out of the box
uvicorn app.main:app --reload # -> http://127.0.0.1:8000/docs
Work the tickets in practicetickets/ (TICKET_01 through TICKET_07); each names one dedicated pytest file:
pytest practicetickets/test_ticket01_upload_size_boundary.py -v # a single ticket
./practicetickets/run_tickets.sh # all 7, clean pass/fail summary
Run run_tickets.sh from anywhere -- it cds to the project root itself before running, since app/main.py resolves its SQLite file and upload directory relative to the working directory at import time. pytest -q tests/ (the project's own pre-existing suite, separate from practicetickets/) is also worth running before and after each fix -- three of the four bugs (tickets 02, 04, 06) also break specific pre-existing tests there, and fixing the ticket correctly should make those green again too, with zero changes needed inside tests/ itself.
Level 1
Fix a bug
Read existing behaviour, correct it.