Repository navigation
fix(api): bound the remaining unbounded request fields [ENG-1652] - #150
Conversation
Semantic search query (4,096) and tenant_id (255), taxonomy run field_label and node rename label (2,048), and enrichment retry names (3) get explicit limits, mirrored in openapi.yaml (1.2.0). Webhook event_types gets maxItems/uniqueItems in the spec, and a rejected field_type is quoted up to 64 characters.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe changes add maximum lengths for semantic-search fields and taxonomy labels, and maximum item counts for webhook event arrays and enrichment retry lists. Validation error reporting now truncates long invalid field-type values. Tests cover these limits and the related OpenAPI schemas. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
xernobyl
left a comment
There was a problem hiding this comment.
Approving. Checked against ENG-1652: every limit from the 10-13 status comment is in, in Go and in openapi.yaml, and info.version is bumped to 1.2.0 with a release note. metrics and the enrichment budget are explicitly out of scope (ENG-3908).
Smoke-tested the PR head against main on real Postgres with an embedding stub. Search query is 200 at 4,096 and 400 at 4,097 (characters, not bytes). Search tenant_id is 200 at 255 and 400 at 256. Taxonomy field_label and rename label are 200 at 2,048 and 400 at 2,049. Retry returns 400 for more than 3 names. A 400 KB field_type now returns about 480 bytes instead of 400 KB. Unit and integration tests, lint and Spectral all pass, and reverting each source change makes its new test fail.
Two optional follow-ups, neither blocking: nothing tests that the spec's maxLength values match the Go validators (only maxItems is pinned), and the docs don't mention the new limits (data-model.mdx lists the feedback-record ones).
What does this PR do?
Fixes ENG-1652
Every request body is already capped (#141). This gives the fields that still had no limit of their own an explicit one, in Go and in
openapi.yaml, so generated SDKs check them client-side too.querytenant_idtenant_idfield_labelfield_labellabelevent_types(create, update)maxItems: 6,uniqueItemsenrichmentsAlso, a rejected
field_typeis now quoted up to 64 characters ininvalid_params, instead of echoing the whole value (up to ~512 KiB) back.Not in this PR:
metricson the internalCompleteRun. The caller is trusted, it is already under the 16 MiB body cap, and real runs' size isn't measured, so a cap could fail them. The enrichment input budget moved to ENG-3908.📝 Release note
Behavior change: more request fields are bounded. These were accepted before and now return
400: a semantic searchqueryover 4,096 characters ortenant_idover 255; a taxonomy runfield_labelor node renamelabelover 2,048; an enrichment retry listing more than 3 names. OpenAPIinfo.version1.1.0 → 1.2.0, with matchingmaxLength/maxItems.How should this be tested?
go test ./cmd/api ./cmd/worker ./internal/...: passgolangci-lintv2.14.0run ./...: 0 issues;fmt --diff: cleannpx @stoplight/spectral-cli@6 lint openapi.yaml: no errorsmain's code:TestSearchHandler_SemanticSearch(over-long cases),TestTaxonomyLabelsAreBounded,TestRetryRefusesMoreNamesThanThereAreEnrichments,TestOpenAPIRequestArrayCapsMatchTheirValues.TestRespondErrorInvalidFieldTypeReasonTruncatesLongValuefails once the truncation ininvalidFieldTypeParamis removed.make tests(no local test DB) and Schemathesis. CI runs both.Checklist
Required
make buildmake tests(integration tests intests/)make fmtandmake lint; no new warningsgit pull origin mainmigrations/with goose annotations and ranmake migrate-validateAppreciated
make testsor API contract workflow)docs/if changes were necessarymake tests-coveragefor meaningful logic changes