Files
document-haness/docs/clean-architecture-backend-template/tech-log-studio/schema-and-wire-models/concept/concept-messaging-schema-json-c03.md
T
DongHyeonkaandClaude Opus 5 b2963105a8 docs(keycloak-session-store): import the session-storage lab as a new project
The keycloak project ended with four open questions that design could not
settle. A two-VM lab was built to answer them by measurement, and this is
that material: 26 experiments, 125 raw command outputs, 22 browser captures.

Follows the import procedure in README.md.

  source/     the originating repository verbatim — 78 documents, 28 SVGs,
              8 manifests, plus .source-revision recording the commit
  final/      the SSOT
    document.md   729 lines written from the 29 experiment documents, not
                  concatenated: what was predicted, what was measured, and
                  where the measurement itself was wrong
    evidence/raw    125 outputs, flattened to <experiment>__<file> because
                    the originals collided (01-baseline.txt appeared three
                    times) and the audit only globs the top level
    evidence/meta   one per raw file; command and exitCode are null and the
                    README says why rather than inventing them
    evidence/browser  22 captures
    assets/       three diagrams through techviz
    .techviz/     their VizSpecs

A separate project rather than an addition to keycloak: the B-layer answers
that project's four questions, but the A, C and D layers are about cluster
failure, SSO and operations, and one document.md should hold one subject.
The four question records there can point here through 관계.

Recorded rather than papered over: only three of the 28 diagrams were
remade. The repository forbids hand-drawn SVG and forbids titles inside the
canvas; all 28 originals carry both, so converting them is redrawing, not
reformatting. They stay in source/ and the gap is written into the document.

verify-pipeline.py passes. audit-records.py reports no issues.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 22:51:59 +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:
- 원본 분석 절은 analysis/messaging/messaging-schema-json.md#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 -->