Files
document-haness/docs/clean-architecture-backend-template/tech-log-studio/schema-and-wire-models/concept/concept-messaging-schema-json-c03.md
T
DongHyeonkaandClaude Fable 5.1 b25357c48a docs(clean-architecture-backend-template): fold analysis into final and re-select one topic
- analysis/·source-index·state.json 을 final/document.md 제2부·제3부로 접었다. SSOT 는 하나다
- 파일럿 — commit-ambiguity-as-a-result 를 새 기준으로 재선별. 후보 14 → 글감 5
  (PROMOTE 5 · MERGE_INTO 3 · KEEP_IN_SSOT 4 · 보류 2). 기록 5건을 다시 썼고 그림 1개를
  techviz 로 만들었다
- 재선별이 잡은 것: 제1부 §6.2·§11.1 이 자기 §13.2 와 어긋나 있었다(레인을 안 돌렸다 vs
  돌렸다) — 정정. 이미 답이 나와 있던 Question 을 HEAD 재실행 질문으로 다시 세웠다.
  Concept 이 인용한 코드가 SSOT 에 없어 뺐다
- candidateScope·sourceRepository 기록. 나머지 43개 주제는 재선별 대기(PENDING 905)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-07 12:39:20 +09:00

62 lines
3.2 KiB
Markdown

---
kind: CONCEPT
slug: messaging-schema-json-c03
title: 인코딩 상한과 파서 상한이 하나의 값에서 나온다
topic: schema-and-wire-models
project: clean-architecture-backend-template
status: 게시 전
sourceRevision: 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916
rootTreeNode: concept:messaging-schema-json-c03
evidenceCapturedOn: 2026-09-01
assets:
- key: messaging-schema-json-c03
file: ../../../final/evidence/rendered/messaging-schema-json-c03.svg
evidence:
- ../../../final/evidence/raw/messaging-schema-json-c03.txt
source:
- 원본 분석 절은 final/document.md#a19-messaging-schema-json#L124 이다.
module: messaging-schema-json
---
# 인코딩 상한과 파서 상한이 하나의 값에서 나온다
여섯 가지 방어가 한 곳에 있다. 그리고 polymorphic default typing을 켜지 않는다.
## 관계
- **실패 코드는 운영자의 다음 행동이 갈리는 지점마다 나눈다**
같은 분석 리프에서 끌어낸 규칙이다.
## 본문
<!-- body:start -->
여섯 가지 방어가 한 곳(`strictMapper`)에 있다 — `maxNestingDepth`(100), `maxDocumentLength`(codec 상한), `maxNumberLength`(1,000), `maxStringLength`·`maxNameLength`(5,000,000), `STRICT_DUPLICATE_DETECTION`, 그리고 `FAIL_ON_READING_DUP_TREE_KEY`·`FAIL_ON_TRAILING_TOKENS`·`FAIL_ON_UNKNOWN_PROPERTIES`. 그리고 **polymorphic default typing을 켜지 않는다** — javadoc이 그것이 대부분의 JSON gadget chain의 기반이라고 적는다.
## 두 상한이 갈라지지 않는다
`maxDocumentLength``maxBytes`와 같다는 점이 중요하다 — 인코딩 상한과 디코딩 파서 상한이 하나의 값에서 나온다. 따로 두면 둘이 갈라진다.
## MessageTooLargeException 참조 위치
:::evidence key="messaging-schema-json-c03" alt="코드베이스에서 MessageTooLargeException 를 검색한 출력 8줄. 이 기록이 세는 참조가 그 출력에 그대로 보인다." caption="MessageTooLargeException 코드베이스 검색 — 8줄 · exit 0" zoom="true"
:::
## 증분 쓰기라 한도에서 멈춘다
주석이 이유를 적는다 — "Jackson writes incrementally, so a payload whose serialized form is far larger than the limit stops at the limit instead of after the whole graph has been rendered into a buffer nobody bounded."
## unwrapTooLarge 가 원인 사슬을 훑는다
`for (Throwable cause = exception; cause != null; cause = cause.getCause())` — 끝까지 훑어 `MessageTooLargeException`을 찾는다. 못 찾으면 `MessageSerializationException("JSON_ENCODE_FAILED")`.
## 에러 메시지만으로 운영자가 판단할 수 있다
`SCHEMA_VERSION_NOT_REGISTERED` 메시지에는 `registeredVersions(type)`가 정렬되어 포함된다. 테스트가 그 내용을 직접 단언한다 — `hasMessageContaining("order.created v999").hasMessageContaining("[1, 2]")`(`JsonContractRegistryTest.java:58-61`).
## 인코딩과 디코딩의 비대칭
인코딩에서 `OrderCreated`의 하위 타입을 넘기면 Jackson이 등록된 형태로 직렬화한다. 디코딩에서 하위 타입을 허용하면 등록된 계약과 다른 클래스로 역직렬화되므로 정확 일치여야 한다. 다만 이 비대칭은 주석으로 설명되지 않았다 — §15의 추론 항목이다.
<!-- body:end -->