fix(query): 재전송 거절의 결과 불명 해제를 짝 백엔드 표 code로만 정한다
문제: 80e7f1d의 isRefusedOnEveryAttempt는 kind가 VALIDATION_REJECTED면 code를 보지 않고 참을 돌려준다. 그 kind는 기능의 mapProblem이 정한다. 생성기는 선언한 <FEATURE>_INVALID를 VALIDATION_REJECTED로 옮기고 (scripts/create-feature-write-slice.ts mapProblem), 참조 기능 gateway는 code와 상관없이 모든 422를 그렇게 옮긴다(reference-http-gateway.ts). 그래서 기능이 선언한 code나 422 IDEMPOTENT_REQUEST_MISMATCH로 끝난 같은 키 재전송이 결과 불명을 푼다. 함수 주석, CHANGELOG, 런북 6.3-4는 이것들이 결과 불명으로 남는다고 적는다. 기존 테스트는 mapProblem 없이 실패를 만들어 이 길을 타지 않았다(최종 리뷰 FR-01). 고른 방법(메인 세션 결정 "D10 보완 2"): 재전송 거절은 짝 백엔드 표의 code일 때만 결과 불명을 푼다. 지금은 400 VALIDATION_FAILED와 400 IDEMPOTENCY_KEY_INVALID다(REFUSALS_OF_EVERY_ATTEMPT, code와 status 함께). kind 줄을 지우고 kind로 입력 검증을 말하던 주석과 런북 6.3-4를 고쳤다. 기능 code는 상태 규칙일 수 있어 mapProblem이 정한 kind를 믿지 않는다. 400 VALIDATION_FAILED는 필드 목록이 있든 없든 전처럼 푼다. 테스트: 훅의 결과 불명 유지 it.each에 mapProblem 모양(VALIDATION_REJECTED + 선언 code, VALIDATION_REJECTED + 422 IDEMPOTENT_REQUEST_MISMATCH) 두 행을 더했다. 참조 페이지에서 422 재전송이 필드 오류와 다시 저장을 보인다던 테스트를, 결과 불명이 남고 확인이 보이는 테스트로 바꿨다. 리뷰가 요청한 대로 다시 마운트한 폼이 다른 값을 보이는 채 재전송해 422 IDEMPOTENT_REQUEST_MISMATCH를 받으면 결과 불명과 확인 버튼이 남는 테스트를 더했다. 버린 대안: kind 줄을 남기고 기능 선언 code만 빼기(실행기는 code가 선언인지 폼과 훅에 알리지 않는다). 위험·한계: 참조 기능처럼 problem details를 읽는 기능의 422 입력 검증은 재전송 뒤 결과 불명으로 남는다. 출구는 결과 불명 화면의 확인이다. 리뷰 실험 03-R1 X1~X3·X5는 그대로 키가 모두 key-1이어야 한다. CHANGELOG는 다음 커밋이 적는다. 검증: desktop batch에서 확인. node scripts/run-vitest.ts run tests/component/application-mutation-admission.test.tsx tests/features/reference-feature/reference-page.test.tsx tests/component/form-foundation.test.tsx tests/unit/backend-envelope.test.ts, 리뷰 실험 03-R1 패치를 이 커밋에 적용 Refs: 1106/03-01 (final review FR-01)
This commit is contained in:
@@ -260,17 +260,18 @@ export const REFUSALS_OF_EVERY_ATTEMPT: Readonly<Record<string, number>> =
|
||||
});
|
||||
|
||||
/**
|
||||
* 1106/03-01 (D10 supplement). A `NOT_APPLIED` refusal the same request gets
|
||||
* on every attempt: input validation (`VALIDATION_REJECTED`) or a row above.
|
||||
* A resend of an unknown request that meets one shows the first attempt was
|
||||
* refused too, so the request is settled. Not one: a refusal before the
|
||||
* idempotency check or one that changes over time (429, 401, 403, 503
|
||||
* RATE_LIMIT_*), a code a feature declared refused before its write (it may
|
||||
* be a rule on changing state), any other code, and `NOT_STARTED`.
|
||||
* 1106/03-01 (D10 supplement and its second fix). A `NOT_APPLIED` refusal
|
||||
* the same request gets on every attempt: a row above, code and status
|
||||
* together. A resend of an unknown request that meets one shows the first
|
||||
* attempt was refused too, so the request is settled. Not one: a refusal
|
||||
* before the idempotency check or one that changes over time (429, 401,
|
||||
* 403, 503 RATE_LIMIT_*), a code a feature declared refused before its
|
||||
* write (it may be a rule on changing state), any other code, and
|
||||
* `NOT_STARTED`. The kind is not read: a feature's `mapProblem` sets it, and
|
||||
* it maps its own codes, or every 422, to `VALIDATION_REJECTED`.
|
||||
*/
|
||||
export function isRefusedOnEveryAttempt(failure: AppFailure): boolean {
|
||||
if (failure.effect !== "NOT_APPLIED") return false;
|
||||
if (failure.kind === "VALIDATION_REJECTED") return true;
|
||||
return (
|
||||
Object.hasOwn(REFUSALS_OF_EVERY_ATTEMPT, failure.code) &&
|
||||
REFUSALS_OF_EVERY_ATTEMPT[failure.code] === failure.httpStatus
|
||||
|
||||
@@ -636,10 +636,10 @@ export function useApplicationMutation<Input, Value>(
|
||||
// that this attempt did not apply; the first may have. The request
|
||||
// stays unknown with its intent, so the next save or resend carries
|
||||
// the same key, never a new one (backend http-contract.md §2). A
|
||||
// refusal every attempt of the request gets (input validation, a key
|
||||
// the server's rule rejects) shows the first was refused too, so the
|
||||
// request is settled and the form can take a corrected save
|
||||
// (isRefusedOnEveryAttempt, D10 supplement).
|
||||
// refusal every attempt of the request gets (the paired backend's 400
|
||||
// VALIDATION_FAILED and IDEMPOTENCY_KEY_INVALID) shows the first was
|
||||
// refused too, so the request is settled and the form can take a
|
||||
// corrected save (isRefusedOnEveryAttempt, D10 supplement).
|
||||
const resendLeavesUnknown = (failure: AppFailure): boolean =>
|
||||
replayed !== undefined &&
|
||||
(!scope || scope.isCurrent()) &&
|
||||
|
||||
Reference in New Issue
Block a user