Repository navigation
Validate payload before WAL publication, fail-fast with 400 - #371
Conversation
- Add PayloadValidator.kt with payload-deterministic nullability rules: INSERT requires every non-nullable field present and non-null; UPDATE rejects explicit null for non-nullable but allows absent fields; DELETE skips property validation (tombstone semantics). - Call validatePayloadNullability in EdgeBulkMutationRequest and MultiEdgeBulkMutationRequest createEvent, before WAL publication. - Add a collectList() barrier in MutationService.mutate so that any validation failure in a bulk request prevents partial WAL publication. - Discriminate IllegalArgumentException in the sync-path onErrorResume so schema violations from the RMW branch surface as HTTP 400 instead of being swallowed as per-item ERROR status. Closes kakao#366 Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
- Extract tableDdl() to remove duplicated DDL between sync/async tables - Extract mutateSync()/mutateAsync() helpers to reduce boilerplate - Remove redundant async valid case (same code path as sync) - Remove Part 1/2A section comments; test names are self-explanatory Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
|
The name |
|
@em3s Two reasons why
@ExceptionHandler(
IllegalStateException::class,
ServerWebInputException::class,
UnsupportedOperationException::class,
IllegalArgumentException::class,
)
fun handleClientError(e: Exception) = createErrorResponse(e, HttpStatus.BAD_REQUEST) { ... }
|
Use intent-revealing names instead of domain-specific ones (score/tag). Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
…aints Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
Reflects em3s's feedback that the name should capture the mutation request validation scope rather than the nullability implementation detail. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
|
@em3s Updated — renamed |
Parameter is List<StructField> + Map<String, Any?>, not a request object. checkNonNullableFields better reflects what is actually being checked. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
|
@em3s One design question — currently Would it be worth moving all error paths to Curious whether you'd prefer keeping the current mixed approach or moving toward uniform error propagation. Update: Scoped this PR down to Part 1 only. The |
… PR) Restores the original catch-all onErrorResume. Part 2 (surfacing RMW-stage validation failures as HTTP 400) is a nice-to-have and will be addressed in a separate follow-up PR. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
…ATE branches Split the single loop into separate INSERT and UPDATE branches to mirror the KDoc contract directly, as suggested in code review. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
|
Since this modifies the write path, we must verify the latency in shadow testing before deploying. Nice work @eazyhozy Merging. |
Summary
Add payload-deterministic schema validation before WAL publication to fail-fast with HTTP 400 on invalid mutation payloads.
Previously, async tables accepted any payload and returned
"QUEUED", with errors silently surfacing only in downstream processor logs. The sync path swallowed validation failures as200 OKwithstatus: "ERROR".Scope: Part 1 of #366 only (validate before WAL, fail-fast 400, incl. all-or-nothing barrier). Part 2 (surfacing RMW-stage validation failures as HTTP 400 instead of
200 + status:ERROR) is deferred to a separate follow-up PR.Closes #366
Changes
MutationRequestValidator.kt(new): Internal helpercheckNonNullableFieldsenforcing nullability rules per event type — INSERT requires all non-nullable fields; UPDATE rejects explicit null for non-nullable but allows absent fields; DELETE is a no-op (tombstone).EdgeBulkMutationRequest/MultiEdgeBulkMutationRequest: CallcheckNonNullableFieldsinsidecreateEvent, before any WAL publish.MutationService: AddcollectList()barrier aftercreateEvent— by eagerly materializing the entireFluxbefore anywriteWalstarts, if even onecreateEventcall throws (= validation failure), the resultingMonoerror propagates immediately and no WAL writes start at all. This prevents partial WAL publication in bulk requests (e.g. 10 mutations, 1 invalid → 0 published, 400).How to Test
New test coverage:
EdgeBulkMutationRequestTest/MultiEdgeBulkMutationRequestTest: unit tests for INSERT/UPDATE/DELETE × nullable/non-nullable field combinations.MutationServiceSpec: invalid INSERT fails before WAL write; bulk with one invalid item errors without publishing any item (all-or-nothing).EdgeMutationValidationTest: E2E —POST /edges(async) and/edges/syncwith invalid payload → 400; valid payload → 200 (regression guard).Scope & Limitations
compatibility stays the existing
PrimitiveType.cast(...)increateEvent(runsbefore WAL): numeric parse failures already return 400, while lenient coercions
remain silent (
"123"→123, any value→StringviatoString(), non-"true"→false, fractional→integer truncation). Stricter type validation is out of scope.collectList()ensures abulk request with any invalid item publishes nothing to the WAL (e.g. 10 mutations,
1 invalid → 0 published, 400). It does not add cross-key transactional writes; the
downstream RMW stage keeps its existing per-key semantics.
AI Assistance