polish: ProblemDetail in inqcust + codify rulebook (#5, #6)#46
Merged
Conversation
- Refactor InqcustController to return ProblemDetail on all error paths, matching every other controller (InqacccuController, CrecustController, CreaccController, ...). failCode moves to a ProblemDetail extension; the human-readable message moves to \$.detail. - Update InqcustControllerTest and InqcustControllerWebMvcTest assertions from \$.message to \$.detail accordingly. - Delete CbsaFailureResponse: the legacy error record had only one user and is now obsolete. - Add docs/translation-rules.md \xc2\xa713 codifying the seven recurring patterns from PR #4 (single error wire shape, defensive null-checks, @Valid on \@RequestBody, deterministic randomness, retry off-by-one, control-baseline preservation, empty-table -> 404). Add \xc2\xa714 translator checklist appendix. Closes #5 Closes #6
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.
Final cleanup-pass PR: brings the last legacy error-shape into line with
the rest of the API, deletes the dead
CbsaFailureResponserecord, andcodifies the seven recurring patterns from the PR #4 INQCUST review into
the rulebook.
Why
InqcustControllerwas the only controller stillserializing a per-program legacy
{failCode, message}record on theerror path; every other controller (
InqacccuController,CrecustController,CreaccController,DelcusController,DelaccController,UpdcustController,UpdaccController,DbcrfunController,XfrfunController) already usesProblemDetail. That made the wire shape of error responsesinconsistent across the API surface.
docs/translation-rules.mdwas missing severalpatterns that recurred across the auto-review of every program PR
(defensive null-checks, deterministic randomness, retry off-by-one,
empty-table → 404, control-baseline preservation, single error wire
shape,
@Validon request bodies). Codifying these closes thefeedback loop the issue called out.
What changed
Code
InqcustControllernow returnsProblemDetailfor all error paths(404 not-found, 503 random-retry-exhausted, 500 abend), matching
InqacccuControllerline-for-line. ThefailCodeis exposed as aProblemDetailextension (pd.setProperty("failCode", ...)); thehuman-readable message goes in
detail.CbsaFailureResponsedeleted — the only caller was the controllerabove. No other production or test code referenced it.
Tests
InqcustControllerTest(integration): not-found assertions updatedfrom
$.messageto$.detail(the$.failCodeextension isunchanged).
InqcustControllerWebMvcTest: random-retry-exhausted assertionupdated from
$.messageto$.detail. The 500/abend tests alreadyasserted on
$.detail/$.abendCodeand required no change.Docs
docs/translation-rules.mdgains §13 ("Recurring patterns from PR feat(inqcust): translate INQCUST to Java #4review") codifying all seven patterns with rationale and a code-shape
example for the
ProblemDetailrule, and §14 ("Translator checklist")— a 9-item bullet list a translator can scan before opening a program
PR. References PR feat(inqcust): translate INQCUST to Java #4 and issues translator: tighten error-shape consistency and overflow guards #5 / translator-rules: codify recurring auto-review patterns #6 as the empirical source.
Existing §13 ("Out of scope") is renumbered to §15.
Acceptance — Issue #5
controller —
InqcustControllerwas the last hold-out.CbsaApplicationclamps the random-customer upper bound (auditedand confirmed pre-existing:
applicationRandom.nextLong(highest) + 1cannot overflow for any positivelong).@RequestBodyparameter is@Valid-annotated(audited).
Acceptance — Issue #6
3:
@Valid, 4: deterministic randomness, 5: retry off-by-one, 6:control-baseline, 7: empty-table → 404).
(the most common source of inconsistency).
seven items as bullets.
Validation
./mvnw -B verify— 205 tests pass (Testcontainers CockroachDB24.3, full integration suite + WebMvc slices).
Closes #5
Closes #6