fix(okw): create endpoint returns 500 on every successful create#206
Merged
Conversation
The handler built OKWUploadResponse with fields the model doesn't have (facility=/facility_id=) while the model requires `okw=`, so response serialization raised on every create — the facility was stored but the caller always got a 500. Construct the response with the correct `okw` field. Adds a TestClient contract regression test (create returns 201 with the okw field). `make ready` green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Urgent bug.
POST /api/okw/createreturns HTTP 500 on every call, even though it stores the facility correctly — so the API path for adding a facility is broken from a caller's perspective (this would bite any real makerspace submitting their data via API/CLI). Surfaced while loading synthetic OKW facilities for the frontend work.Cause
The handler constructed the response with field names the model doesn't define:
but
OKWUploadResponserequiresokw: OKWResponse. Pydantic raised "okw Field required", which the genericexceptturned into a 500 — after the facility was already stored.Fix
Construct the response with the correct field:
Verification
tests/api/test_okw_create_route.py— create returns 201 with theokwfield (would 500 before this fix).make readygreen: 522 passed, parity 4/4, docs ✓.Follow-up (separate)
Process representation in the synthetic OKW data is inconsistent (Wikipedia URIs vs plain names).
ProcessTaxonomy.normalize()already exists to canonicalize these; normalizing the data + updatinggenerate_synthetic_data.pyis a tracked follow-up (lower urgency, and a data-model decision rather than a bugfix).🤖 Generated with Claude Code