--- kind: CONCEPT slug: messaging-schema-api-c03 title: 아무것도 실패하지 않고 잘못된 성공이 나온다 topic: schema-and-wire-models project: clean-architecture-backend-template status: 게시 전 sourceRevision: 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916 rootTreeNode: concept:messaging-schema-api-c03 evidenceCapturedOn: 2026-09-01 assets: - key: messaging-schema-api-c03 file: ../../../final/evidence/rendered/messaging-schema-api-c03.svg - key: messaging-schema-api-c03-diagram file: ../../../final/assets/diagrams/messaging-schema-api-c03.svg evidence: - ../../../final/evidence/raw/messaging-schema-api-c03.txt source: - 원본 분석 절은 final/document.md#a19-messaging-schema-api#L113 이다. module: messaging-schema-api --- # 아무것도 실패하지 않고 잘못된 성공이 나온다 이 leaf에서 가장 밀도 높은 javadoc이다. 핵심은 "Nothing failed"다. ## 관계 - **port 계약은 동시성 요구를 적는다** 같은 분석 리프에서 끌어낸 규칙이다. - **도달성 판정은 단어가 아니라 import로 확인한다** 같은 분석 리프에서 끌어낸 규칙이다. ## 본문 이 leaf에서 가장 밀도 높은 javadoc이다. 타입만으로 키를 잡으면 실패가 발생하지 않고 **잘못된 성공**이 발생한다. 그리고 그 결과에는 등록된 적 없는 버전 라벨이 붙어 하위 감사 기록까지 오염된다. ## 타입만 키로 잡은 경로 :::evidence key="messaging-schema-api-c03-diagram" alt="미등록 버전 라벨이 타입만으로 조회와 이전 파서로 디코딩을 지나 잘못된 성공으로 이어진다" caption="타입만 키로 잡은 경로" zoom="false" ::: ## 세 codec이 두 실패를 구분한다 `JacksonMessageCodec.requireRegistered`, `AvroMessageCodec.schemaFor`, `ProtobufMessageCodec.requireRegistered`가 모두 "타입은 아는데 버전을 모른다"와 "타입 자체를 모른다"를 **다른 에러 코드**로 구분한다(`SCHEMA_VERSION_NOT_REGISTERED` vs `UNKNOWN_MESSAGE_TYPE`). 그 구분이 있어야 운영자가 "등록을 빠뜨렸다"와 "오타다"를 나눌 수 있다. ## JacksonMessageCodec 참조 위치 :::evidence key="messaging-schema-api-c03" alt="코드베이스에서 JacksonMessageCodec 를 검색한 출력 5줄. 이 기록이 세는 참조가 그 출력에 그대로 보인다." caption="JacksonMessageCodec 코드베이스 검색 — 5줄 · exit 0" zoom="true" ::: ## 한도를 미리 잡지 않는다 `new ByteArrayOutputStream(Math.min(maxBytes, 8_192))` — 주석: "a 1 GiB bound must not pre-allocate 1 GiB." ## codec 자기 에러 코드를 그대로 던진다 `errorCode`가 생성자 인자다. 그래서 Avro는 `AVRO_PAYLOAD_TOO_LARGE`, JSON은 `PAYLOAD_TOO_LARGE`가 나온다. 테스트가 이 성질을 직접 단언한다(`BoundedByteSinkTest.java:69-77`, `as("the sink reports the codec's own code, not a generic one")`). ## requireFits 는 예산을 소비하지 않는다 Protobuf는 직렬화 크기를 미리 알므로 첫 바이트 전에 거절할 수 있다. 그 뒤의 쓰기도 여전히 경계 안이다 — 주석: "this is a cheaper refusal, not a replacement for the bound." `refuseIfBeyondLimit`가 `size > maxBytes - written`으로 비교하는 것도 의도적이다.