fix!: 재리뷰가 찾은 결함과 색인에서 빠졌던 발견 5건을 고친다
문제: 성숙도 리뷰 수정을 다시 읽은 재리뷰(Critical 0, 회귀 0)가 Important 27건·Minor 41건을 찾았다. 수정이 새로 만든 결함이 많았다. @SystemInvoked가 권한 규칙의 탈출구가 됐고, 데모 계정 거부가 정확히 prod일 때만 걸렸고, outbox 순서 번호가 업그레이드 때 뒤로 갔고, GraphQL union 아래 복잡도가 0이었고, 서블릿 오류 응답이 success:true로 나갔고, 호출자 deadline이 breaker를 열었다. 원래 리뷰 색인이 06 영역 발견 5건(06-10~14)을 빠뜨려 그동안 처리되지 않았다. 방법: 영역별 7묶음이 test-driven-development 절차로 실패 테스트를 먼저 쓰고 고쳤다. 결정은 재리뷰 README 4절에 적었다: 순서 번호는 V21이 기록한 전역 floor부터, 데모 계정은 local·test·demo 허용 목록, @SystemInvoked bean은 기동 실패, complete 단계 실패는 IDEMPOTENCY_COMPLETION_UNKNOWN(결과 불명), 캐시 조건부 쓰기는 별도 SCRIPT lane, strict lane 정책은 build cache 입력, 끝나지 않는 재시도 행은 원인 코드·지표·PARKED 절차. 레지스트리가 선언만 하고 아무 코드도 내보내지 않던 redis.capability.* 지표 6개는 빼고 runbook을 실제 지표(redis.lane.*) 기준으로 고쳤다. 위험·한계: V21을 V22 없이 직접 고쳤다(어느 배포에도 아직 없음). 이 브랜치의 V21을 적용한 개발 DB는 다시 만들어야 한다. 서블릿 오류 디스패치를 보안 체인이 허용한다. 발행·저장소 포트 시그니처가 바뀌어 파생 서비스 코드가 깨진다. prod에서 fixture-로 시작하는 설정값은 기동을 막는다. httpclient failure-injection lane의 main 단계 중복 실행은 이전 결정대로 남겼다. 실제 CI runner 실행은 확인하지 못했다. 검증: ci, mainCheck, :integrationCheck, -p optional-platforms ci integrationCheck performanceCheck, :performanceCheck, :releaseCheck (-PgitRevision), verify-compose-profile-contracts(18 lane) 통과. 첫 실행의 실패 2건(FindSecBugs 1, sample 동시 생성 테스트의 v4 event id)은 고친 뒤 ci·integrationCheck·mainCheck를 다시 돌려 통과했다. Refs: docs/reviews/2026-11-03-rereview/README.md 3·4·6·7절 BREAKING CHANGE: outbox 발행 포트와 저장소 포트 시그니처, 순서 번호 첫 값(V21 floor 다음), 샘플 데모 계정 프로필 허용 목록, 새 오류 코드 IDEMPOTENCY_COMPLETION_UNKNOWN, prod의 fixture- 값 거부, 기동 rule은 static·의존 없음이어야 한다.
This commit is contained in:
@@ -77,7 +77,12 @@ instrumentation, data fetcher resolver 세 곳이 같은 bean 을 받는다).
|
||||
- **client 문구**: shared-contract `ClientErrorMessages`(Category 별 한국어 문구 표 하나, 소유자
|
||||
결정 11). 예외 메시지는 절대 나가지 않는다.
|
||||
- **retryable**: 코드의 `retryable()` 이다(category 에서 계산하지 않는다). 플랫폼 자체 코드만 wire
|
||||
category 기본값을 쓴다.
|
||||
category 기본값을 쓴다. 그래서 공유 코드의 값을 바꾸면 이 wire 도 바뀐다: 처리 중 중복
|
||||
`IDEMPOTENT_IN_FLIGHT` 는 2026-11-01 리뷰(02-01)부터 `retryable: true` 다 — 같은 키로 다시 보내면 서버가
|
||||
판정한다(`docs/web/http-contract.md` §2). `GraphQlWireErrorMapperTest` 가 고정한다(재리뷰 RR-02-06).
|
||||
- **`REQUEST_TIMEOUT` 은 web 과 이름만 같다.** 여기의 `category` 는 GraphQL wire 전용 6값 어휘(`TIMEOUT`)이고,
|
||||
web 의 같은 이름 코드는 HTTP 503·operational category `TRANSIENT_DEPENDENCY` 다
|
||||
(`docs/web/http-contract.md` §4). 둘 다 `retryable: true` 다.
|
||||
- **body 크기 초과**: `PAYLOAD_TOO_LARGE`(web 과 같은 코드). 문서 모양 거부(`GRAPHQL_DOCUMENT_SHAPE_REJECTED`)는
|
||||
별도 코드.
|
||||
|
||||
|
||||
+3
@@ -14,6 +14,9 @@ import java.time.Instant;
|
||||
* <li>{@code GraphQlPlatformWebInterceptor} ends the request with {@code REQUEST_TIMEOUT} when it
|
||||
* passes, and Spring cancels the execution so no further field is dispatched. A resolver
|
||||
* already running is not interrupted.
|
||||
* <li>{@code GraphQlDeadlineInstrumentation} refuses to start a non-trivial resolver once it has
|
||||
* passed, failing that field with {@code REQUEST_TIMEOUT}; this is what still holds when the
|
||||
* whole execution runs on the request thread and the interceptor's timer starts too late.
|
||||
* <li>{@code GraphQlCostBudgetHandler} refuses to start an execution whose deadline has passed.
|
||||
* <li>{@code GraphQlBatchExecutor} clamps each platform-registered DataLoader batch to what is
|
||||
* left, and stops between chunks once it is spent.
|
||||
|
||||
-5
@@ -121,11 +121,6 @@ public final class GraphQlComplexityCalculator {
|
||||
}
|
||||
}
|
||||
|
||||
/** The effective page size for a connection request. */
|
||||
public int effectivePageSize(Integer first, Integer last) {
|
||||
return first != null ? first : last != null ? last : defaultPageSize;
|
||||
}
|
||||
|
||||
private void requireAllowedPage(Integer requested) {
|
||||
if (requested == null) {
|
||||
return;
|
||||
|
||||
+25
-13
@@ -15,6 +15,7 @@ import graphql.language.Value;
|
||||
import graphql.language.VariableDefinition;
|
||||
import graphql.language.VariableReference;
|
||||
import graphql.schema.GraphQLArgument;
|
||||
import graphql.schema.GraphQLCompositeType;
|
||||
import graphql.schema.GraphQLFieldDefinition;
|
||||
import graphql.schema.GraphQLFieldsContainer;
|
||||
import graphql.schema.GraphQLList;
|
||||
@@ -59,6 +60,13 @@ import java.util.Objects;
|
||||
* <p>Pricing an omitted argument as one row was the bypass: {@code items(first: 20)} scored 410
|
||||
* while {@code items} scored 40, and four nested lists added up instead of multiplying.
|
||||
*
|
||||
* <p>A selection set is walked whatever kind of composite type it selects from. A union has no
|
||||
* fields of its own — only {@code __typename} — so its selections are inline fragments and fragment
|
||||
* spreads, each priced against its type condition. Treating "not a fields container" as "nothing
|
||||
* below" was the second bypass (re-review 2026-11-03, RR-02-01): {@code search { ... on Post {
|
||||
* comments(first: 100000) } }} scored 20, and neither the budget nor the page maximum applied under
|
||||
* any union-typed field.
|
||||
*
|
||||
* <p>Traversal is bounded, and fragment cycles are cut by tracking the expansion path. This runs on
|
||||
* documents that have passed validation, but the bound stays because the scorer is also used from
|
||||
* the pre-execution path where a hostile document is exactly what it is meant to price.
|
||||
@@ -143,7 +151,7 @@ public final class GraphQlDocumentComplexityScorer {
|
||||
|
||||
private long selectionSetCost(
|
||||
GraphQLSchema schema,
|
||||
GraphQLFieldsContainer parent,
|
||||
GraphQLCompositeType parent,
|
||||
SelectionSet selectionSet,
|
||||
Map<String, FragmentDefinition> fragments,
|
||||
PageVariables variables,
|
||||
@@ -173,10 +181,10 @@ public final class GraphQlDocumentComplexityScorer {
|
||||
expansionPath,
|
||||
listsAreThePage));
|
||||
} else if (selection instanceof InlineFragment inlineFragment) {
|
||||
GraphQLFieldsContainer target =
|
||||
GraphQLCompositeType target =
|
||||
inlineFragment.getTypeCondition() == null
|
||||
? parent
|
||||
: fieldsContainer(schema, inlineFragment.getTypeCondition().getName());
|
||||
: compositeType(schema, inlineFragment.getTypeCondition().getName());
|
||||
total =
|
||||
GraphQlComplexityCalculator.saturatedAdd(
|
||||
total,
|
||||
@@ -196,10 +204,10 @@ public final class GraphQlDocumentComplexityScorer {
|
||||
if (fragment == null || expansionPath.contains(spread.getName())) {
|
||||
continue;
|
||||
}
|
||||
GraphQLFieldsContainer target =
|
||||
GraphQLCompositeType target =
|
||||
fragment.getTypeCondition() == null
|
||||
? parent
|
||||
: fieldsContainer(schema, fragment.getTypeCondition().getName());
|
||||
: compositeType(schema, fragment.getTypeCondition().getName());
|
||||
expansionPath.push(spread.getName());
|
||||
total =
|
||||
GraphQlComplexityCalculator.saturatedAdd(
|
||||
@@ -221,7 +229,7 @@ public final class GraphQlDocumentComplexityScorer {
|
||||
|
||||
private long fieldCost(
|
||||
GraphQLSchema schema,
|
||||
GraphQLFieldsContainer parent,
|
||||
GraphQLCompositeType parent,
|
||||
Field field,
|
||||
Map<String, FragmentDefinition> fragments,
|
||||
PageVariables variables,
|
||||
@@ -235,8 +243,12 @@ public final class GraphQlDocumentComplexityScorer {
|
||||
return 0;
|
||||
}
|
||||
|
||||
GraphQLFieldDefinition definition = parent.getFieldDefinition(field.getName());
|
||||
String coordinate = parent.getName() + "." + field.getName();
|
||||
// A union declares no fields; validation rejects anything but __typename directly under one.
|
||||
GraphQLFieldDefinition definition =
|
||||
parent instanceof GraphQLFieldsContainer container
|
||||
? container.getFieldDefinition(field.getName())
|
||||
: null;
|
||||
if (definition == null) {
|
||||
// Validation rejects an unknown field; price what is there rather than invent a type.
|
||||
return calculator.fieldCost(coordinate, 0).total();
|
||||
@@ -250,7 +262,7 @@ public final class GraphQlDocumentComplexityScorer {
|
||||
long childCost =
|
||||
selectionSetCost(
|
||||
schema,
|
||||
fieldsContainer(definition.getType()),
|
||||
compositeType(definition.getType()),
|
||||
field.getSelectionSet(),
|
||||
fragments,
|
||||
variables,
|
||||
@@ -353,14 +365,14 @@ public final class GraphQlDocumentComplexityScorer {
|
||||
};
|
||||
}
|
||||
|
||||
private static GraphQLFieldsContainer fieldsContainer(GraphQLSchema schema, String typeName) {
|
||||
GraphQLType type = schema.getType(typeName);
|
||||
return fieldsContainer(type);
|
||||
private static GraphQLCompositeType compositeType(GraphQLSchema schema, String typeName) {
|
||||
return compositeType(schema.getType(typeName));
|
||||
}
|
||||
|
||||
private static GraphQLFieldsContainer fieldsContainer(GraphQLType type) {
|
||||
/** The object, interface or union a selection set selects from; null for a leaf type. */
|
||||
private static GraphQLCompositeType compositeType(GraphQLType type) {
|
||||
GraphQLType unwrapped = unwrap(type);
|
||||
return unwrapped instanceof GraphQLFieldsContainer container ? container : null;
|
||||
return unwrapped instanceof GraphQLCompositeType composite ? composite : null;
|
||||
}
|
||||
|
||||
private static GraphQLType unwrap(GraphQLType type) {
|
||||
|
||||
+96
-2
@@ -34,11 +34,19 @@ class GraphQlDocumentComplexityScorerTest {
|
||||
pagedWithDefault(first: Int = 50): [Item!]!
|
||||
itemConnection(first: Int): ItemConnection
|
||||
node: Item
|
||||
allItems: [Item!]!
|
||||
search: [SearchResult!]!
|
||||
nodes: [Named!]!
|
||||
}
|
||||
type Item {
|
||||
union SearchResult = Item
|
||||
interface Named {
|
||||
name: String!
|
||||
}
|
||||
type Item implements Named {
|
||||
name: String!
|
||||
children: [Item!]!
|
||||
grid: [[Item!]!]!
|
||||
paged(first: Int): [Item!]!
|
||||
}
|
||||
type ItemConnection {
|
||||
edges: [ItemEdge!]!
|
||||
@@ -48,10 +56,15 @@ class GraphQlDocumentComplexityScorerTest {
|
||||
}
|
||||
""";
|
||||
|
||||
// Pricing never resolves a runtime type; the resolvers only satisfy the schema generator.
|
||||
private static final GraphQLSchema SCHEMA =
|
||||
new SchemaGenerator()
|
||||
.makeExecutableSchema(
|
||||
new SchemaParser().parse(SDL), RuntimeWiring.newRuntimeWiring().build());
|
||||
new SchemaParser().parse(SDL),
|
||||
RuntimeWiring.newRuntimeWiring()
|
||||
.type("SearchResult", type -> type.typeResolver(environment -> null))
|
||||
.type("Named", type -> type.typeResolver(environment -> null))
|
||||
.build());
|
||||
|
||||
private static final long BUDGET = 10_000;
|
||||
|
||||
@@ -246,6 +259,87 @@ class GraphQlDocumentComplexityScorerTest {
|
||||
assertThat(score).isEqualTo(20L + 20L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("union 필드 아래 inline fragment 의 중첩 list 도 일반 list 와 같이 곱한다")
|
||||
void nestedListsUnderAUnionFieldMultiplyLikeAPlainList() {
|
||||
// given
|
||||
String plain = "query Q { allItems { children { children { children { name } } } } }";
|
||||
|
||||
// when
|
||||
long score =
|
||||
score(
|
||||
"query Q { search { ... on Item { children { children { children { name } } } } } }",
|
||||
Map.of());
|
||||
|
||||
// then
|
||||
assertThat(score).isEqualTo(score(plain, Map.of()));
|
||||
assertThatThrownBy(() -> calculator.verify(new GraphQlComplexityResult(score), BUDGET))
|
||||
.isInstanceOf(GraphQlComplexityRejectedException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("union 필드 아래 fragment spread 도 그 타입으로 내려가 곱한다")
|
||||
void aFragmentSpreadUnderAUnionFieldIsPricedAgainstItsTypeCondition() {
|
||||
// given
|
||||
String plain = "query Q { allItems { children { children { children { name } } } } }";
|
||||
|
||||
// when
|
||||
long score =
|
||||
score(
|
||||
"query Q { search { ...F } } "
|
||||
+ "fragment F on Item { children { children { children { name } } } }",
|
||||
Map.of());
|
||||
|
||||
// then
|
||||
assertThat(score).isEqualTo(score(plain, Map.of()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("union 필드 아래 page 인자도 상한을 넘으면 page size exceeds maximum 으로 거부된다")
|
||||
void aPageSizeUnderAUnionFieldIsCheckedAgainstTheMaximum() {
|
||||
// given
|
||||
String document = "query Q { search { ... on Item { paged(first: 100000) { name } } } }";
|
||||
|
||||
// when
|
||||
Throwable thrown = catchThrowable(() -> score(document, Map.of()));
|
||||
|
||||
// then
|
||||
assertThat(thrown)
|
||||
.isInstanceOf(GraphQlComplexityRejectedException.class)
|
||||
.hasMessageContaining("page size exceeds maximum");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("interface 필드 아래 inline fragment 의 중첩 list 도 일반 list 와 같이 곱한다")
|
||||
void nestedListsUnderAnInterfaceFieldMultiplyLikeAPlainList() {
|
||||
// given
|
||||
String plain = "query Q { allItems { children { children { children { name } } } } }";
|
||||
|
||||
// when
|
||||
long score =
|
||||
score(
|
||||
"query Q { nodes { ... on Item { children { children { children { name } } } } } }",
|
||||
Map.of());
|
||||
|
||||
// then
|
||||
assertThat(score).isEqualTo(score(plain, Map.of()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("interface 필드 아래 page 인자도 상한을 넘으면 page size exceeds maximum 으로 거부된다")
|
||||
void aPageSizeUnderAnInterfaceFieldIsCheckedAgainstTheMaximum() {
|
||||
// given
|
||||
String document = "query Q { nodes { ... on Item { paged(first: 100000) { name } } } }";
|
||||
|
||||
// when
|
||||
Throwable thrown = catchThrowable(() -> score(document, Map.of()));
|
||||
|
||||
// then
|
||||
assertThat(thrown)
|
||||
.isInstanceOf(GraphQlComplexityRejectedException.class)
|
||||
.hasMessageContaining("page size exceeds maximum");
|
||||
}
|
||||
|
||||
private long score(String source, Map<String, Object> variables) {
|
||||
return score(calculator, source, variables);
|
||||
}
|
||||
|
||||
+23
@@ -55,6 +55,29 @@ class GraphQlWireErrorMapperTest {
|
||||
.containsExactly("DB_QUERY_CANCELED", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* The in-flight duplicate's {@code retryable} became {@code true} in the 2026-11-01 review
|
||||
* (02-01): a resend with the same key is judged by the server, so it is safe. GraphQL carries the
|
||||
* code's own value, so the change reached this wire too; this pins it (re-review RR-02-06).
|
||||
*/
|
||||
@org.junit.jupiter.api.Test
|
||||
@DisplayName("처리 중 중복(IDEMPOTENT_IN_FLIGHT)은 GraphQL extension 에서도 retryable=true 로 나간다")
|
||||
void anInFlightDuplicateIsRetryableOnTheGraphQlWire() {
|
||||
// given
|
||||
GraphQlWireErrorMapper mapper = GraphQlWireErrorMapper.masking();
|
||||
RuntimeException failure =
|
||||
dev.caskeleton.application.idempotency.IdempotencyInFlightException.forScopeDigest(
|
||||
"digest");
|
||||
|
||||
// when
|
||||
GraphQlWireError error = mapper.map(failure, GraphQlErrorContext.test());
|
||||
|
||||
// then
|
||||
assertThat(error.extensions())
|
||||
.extracting(extensions -> extensions.get("code"), extensions -> extensions.get("retryable"))
|
||||
.containsExactly("IDEMPOTENT_IN_FLIGHT", true);
|
||||
}
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
void anIllegalArgumentIsABadParameterRequestError() {
|
||||
// given
|
||||
|
||||
Reference in New Issue
Block a user