Skip to content

fix(okw): create endpoint returns 500 on every successful create#206

Merged
touchthesun merged 1 commit into
mainfrom
fix/okw-create-500-response
Jul 3, 2026
Merged

fix(okw): create endpoint returns 500 on every successful create#206
touchthesun merged 1 commit into
mainfrom
fix/okw-create-500-response

Conversation

@touchthesun

Copy link
Copy Markdown
Contributor

Urgent bug. POST /api/okw/create returns 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:

return OKWUploadResponse(facility=okw_response, facility_id=str(facility.id))

but OKWUploadResponse requires okw: OKWResponse. Pydantic raised "okw Field required", which the generic except turned into a 500 — after the facility was already stored.

Fix

Construct the response with the correct field:

return OKWUploadResponse(success=True, message=..., okw=okw_response)

Verification

  • New TestClient contract test tests/api/test_okw_create_route.py — create returns 201 with the okw field (would 500 before this fix).
  • make ready green: 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 + updating generate_synthetic_data.py is a tracked follow-up (lower urgency, and a data-model decision rather than a bugfix).

🤖 Generated with Claude Code

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>
@touchthesun touchthesun merged commit 545fc84 into main Jul 3, 2026
5 checks passed
@touchthesun touchthesun deleted the fix/okw-create-500-response branch July 3, 2026 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants