Skip to content

feat(problem): a problem missing a param its message needs is sent as its status's problem - #10

Merged
giraffesyo merged 1 commit into
canaryfrom
feat/required-params
Oct 1, 2026
Merged

giraffesyo merged 1 commit into
canaryfrom
feat/required-params

Conversation

@giraffesyo

Copy link
Copy Markdown
Member

Summary

A type can declare Params its localized message uses, but nothing made a handler pass them. Without one, a client formatting the message gets use-intl's fallback, the raw key (apiErrors.name_taken), instead of a sentence.

Now the problem itself guarantees it:

  • Type.New and At/AtParameter remember the type's declared params.
  • Problem.MarshalJSON sends a problem missing one as the about:blank problem for its status (keeping status, detail and instance). FieldError.MarshalJSON sends a field error missing one as the invalid rule, keeping its location. This covers problem.Write, huma's serializer, and anything else that encodes a problem.
  • (*Problem).Resolve() returns a problem as it will be sent, for callers that build another representation from it (core's legacy error envelope).
  • README documents it, and drops a leftover "document the codes" step from before fix(problem)!: adding a problem code no longer changes an API's OpenAPI types #6.

Testing

  • make check
  • TestMissingParamIsSentAsStatusProblem and TestFieldMissingParamIsSentAsInvalid decode the sent JSON with and without the param.

Checklist

  • make check passes
  • A new or changed shared message is in every language in packages/problem/src/messages/ (none changed)
  • No code, rule or param was renamed (they are API contract)

@giraffesyo
giraffesyo merged commit 920f654 into canary Oct 1, 2026
3 checks passed
@giraffesyo
giraffesyo deleted the feat/required-params branch October 1, 2026 01:32
@github-actions github-actions Bot mentioned this pull request Oct 1, 2026
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.

1 participant