openapi
Technical notes on web development, DevOps, and AI integration.
15 articles
- 11:47backend
The Only Admin Module Without a Write Guard
An authorization audit found seven of eight admin modules guarded. The last one closed by reusing the pattern already in the codebase.
TL;DR: The KotaPortal service portal project had an admin module without a scope check. The fix reused a guard pattern from neighboring modules. The handler now passes middleware into the service with a two-function guard.
#go#security#rbac - 22:48frontend
Three 7-Line Routes, One 471-Line Component
The Kelembagaan admin module: three 7-14 line server routes, one 471-line client editor, a 350 ms debounced list, and an id guard that throws 404.
TL;DR: Commit c50f35b adds the Kelembagaan module. It includes organization list and edit forms with validation. Validation occurs on the server side for security.
#nextjs#react#typescript - 23:55backend
Plain Date, Not Instant: the event_date Contract at KotaPortal
The admin event_date once left the browser as an instant T00:00:00Z. The contract now requires a plain YYYY-MM-DD string, with Go validation rejecting instants outright.
TL;DR: A calendar-date field was leaking through the API as a UTC midnight instant, silently accepted by lenient MariaDB and patched over client-side with toLocalDateInput. The fix changes the contract itself: format date, a string DTO, validation at the service edge with a 400 on bad input. Regenerated frontend types now reject instants at compile time, killing the timezone-drift bug class.
#api#openapi#go - 00:13backend
When a Comma Cuts the Description: YAML Under the Linter
Eight of ten OpenAPI lint errors were not contract drift: an unquoted comma in a flow-mapping description became a bogus null-keyed entry.
TL;DR: Ten OpenAPI lint errors weren't contract drift but YAML parsing: unquoted commas inside flow mappings silently truncate description values. Linting grades the parsed debris, not the source, so Redocly flagged symptoms far below the real cause. Quoting descriptions fixed it; openapi-typescript regeneration produced byte-identical output, proving the fix was pure hygiene.
#openapi#yaml#api - 16:01testing
The QA Spec Was Done by 9 a.m., Then the Owner Said: Too Narrow
The QA backfill spec was pushed at 9 a.m. and widened by the owner minutes later: lock current behavior, measure a baseline, retest one full vertical slice.
TL;DR: Initial plan focused only on validator unit tests, but coverage alone doesn't prove correctness and misses cross-field validation. Owner shifted scope to measure baseline first, then retest one full vertical slice from database to UI with contract checks. Findings now go to an owner decision list instead of silent fixes, keeping characterization tests honest.
#testing#go#openapi - 16:24backend
An Undocumented 404 Is a Contract Bug
Six lines of OpenAPI YAML and a regeneration changed what the frontend compiler knows. Error responses left undocumented are contract bugs.
TL;DR: What looked like a trivial six-line OpenAPI cleanup turned out to be critical for type safety. Since openapi-typescript only generates types for explicitly documented responses, an undocumented 404 forced the frontend to guess or use any. Documenting the error locks the contract so TypeScript catches missing handling early, saving hours of debugging later.
#openapi#api#typescript - 15:07backend
The Category Trash Can: One Endpoint and POST Restore
A soft delete API contract: the trashed query flag, POST restore, and a 404 that deliberately merges two conditions.
TL;DR: The categories list supports a trashed query param defaulting to false so existing clients keep seeing active items while new UIs can fetch soft-deleted ones. Restore is a POST endpoint returning 200 on success, 403 when out of scope, or a shared 404 for missing or not-trashed cases. It's a clean additive contract-first change that keeps compatibility without new endpoints.
#api#openapi#rest-api - 14:21backend
When API Contract Descriptions Lie
A field description calling jenis a pillar and an admin_note exception that never existed: two lying contract descriptions, plus an undocumented 400.
TL;DR: I noticed the spec wrongly called the jenis field a service pillar instead of its read-only application kind and claimed admin_note was ignored for Submission. The history endpoint also lacked its documented 400 response for malformed IDs. Fixing both descriptions and adding the error response corrected the docs and the generated frontend types.
#api#openapi#typescript - 12:25frontend
Per-Status Counters in Admin Stats: Numbers From the Contract
Per-status snapshot counters joined AdminLayananStats additively; legacy fields kept, UI derives numbers from stats, no more meta.total tricks.
TL;DR: The dashboard showed dashes because the stats API only counted two of six statuses, leaving legacy fields at zero. The fix kept the old fields and added six current snapshot counters, with regenerated types now requiring a count for every tab and card. Counts respect user scope, and the queue badge now reads the submission counter directly with lightweight polling.
#go#api#openapi