Repository navigation
Add AnswerRequired precondition reason and carry the reason in details - #20
amicklerTMM wants to merge 2 commits into
Conversation
amicklerTMM
commented
Nov 5, 2026
- PreconditionFailedReason.AnswerRequired = 4, with a default message.
- One reason-to-status map (PreconditionFailedReasonHttpExtensions) shared by the MVC and Minimal API adapters; AnswerRequired maps to 422.
- Problem-details bodies for a precondition failure carry a "reason" extension member.
- Precondition theories enumerate every reason instead of a hard-coded list.
…m details - PreconditionFailedReason.AnswerRequired = 4, with a default message. - One reason-to-status map (PreconditionFailedReasonHttpExtensions) shared by the MVC and Minimal API adapters; AnswerRequired maps to 422. - Problem-details bodies for a precondition failure carry a "reason" extension member. - Precondition theories enumerate every reason instead of a hard-coded list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add an AnswerRequired precondition reason, and carry the reason in problem detailsJanus (Portal) has been running a private copy of this kernel and is moving onto the package. The last difference its clients rely on is one precondition reason: an operation that can't go ahead until the caller answers a question. This PR adds that reason, and adds the reason to problem-details bodies so clients can branch on it without parsing the title. ChangesF23.Kernel
F23.Kernel.AspNetCore
Points for review
Tests
|
There was a problem hiding this comment.
Thanks for this. The shared reason-to-status map, the reason member in problem details, and the theories that enumerate every reason are all good generic improvements, and I'd like to land them.
My hesitation is with AnswerRequired itself. The existing reasons describe the state of the resource: it doesn't exist (NotFound), the caller's version is stale (ConcurrencyMismatch), or its state conflicts with the request (Conflict). They're generic to any API and map cleanly onto HTTP semantics. AnswerRequired describes an interaction protocol, where the server needs more input from the caller. That's application workflow rather than resource state, and the kernel can only half-support it: it can say an answer is needed, but not what the question is, so consumers still need their own convention to carry the question.
What clients need is a value they can branch on that isn't the title. Could the kernel provide that generically instead? For example:
- Add an optional code to
PreconditionFailedResult, such asstring? Codeor an extensions dictionary, and write it into problem details next toreason. - An app returns
Conflict, or whichever existing reason fits, withCode = "AnswerRequired". With the extensions route, the question data can travel in the same response.
That keeps the enum to general HTTP concepts and avoids the new-enum-value breaking change for consumers. It also gives any app a place for its own app-specific cases.
Suggestion: split this PR. Land the shared map, the reason member and the test changes, and replace AnswerRequired with the code/extensions mechanism.
One question: do your clients depend on the 422 status itself, or only on being able to tell this case apart? If the status matters, the code approach alone won't cover it, and we should talk about that.
Review feedback: AnswerRequired describes an interaction protocol rather than resource state, so it doesn't belong in PreconditionFailedReason. The app-specific case moves to an optional code on the result, in a separate PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This PR now contains only the generic parts: the shared reason-to-status map, the reason member in problem details, and the theories that enumerate every reason. AnswerRequired is gone, so PreconditionFailedReason is unchanged from 0.3.0 and there's no new-enum-value break. I think I can skip the code entirely and use ValidationFailed, as it will provide the field that is missing in its response and we can branch off of that, and missing a required field is actually a validation error. The 422 itself is not required. |