Repository navigation
Description
Problem
Non-retryable bad requests — mutation payloads that are invalid regardless of current state (e.g., a missing nullable: false property, or a property/source/target value that fails type casting) — fail silently in two places:
1. Async tables — WAL published before validation.
MutationService.mutate publishes to WAL at MutationService.kt:55 and returns "QUEUED" before any payload validation. Validation only runs in the read-modify-write branch, which async requests skip. Clients see "QUEUED" as success; the error surfaces only in downstream async-processor logs, and non-retryable entries pollute the WAL.
2. Sync write — schema errors return 200 OK with body status:"ERROR".
Validation exceptions are caught at MutationService.kt:66-68 and packed into MutationResult.status; the controller hardcodes ResponseEntity.ok(...) at EdgeMutationController.kt:45. HTTP status carries no signal, so retry logic keyed on HTTP status misclassifies non-retryable bad requests.
Reproduction
POST /graph/v3/databases/{db}/tables/{table}/edges to an ASYNC-mode table with a nullable: false property omitted → returns "QUEUED". When the downstream processor retries synchronously → 200 OK with item status: "ERROR".
Proposed Solution
Scope: PR #371 implements Part 1 only. Part 2 is a nice-to-have, deferred to a separate follow-up PR.
Part 1 — Validate all payload-deterministic constraints before WAL publication.
Add a payload-only validator in MutationService.mutate before engine.writeWal(...) (MutationService.kt:54-55) that rejects any error determinable from the payload + schema alone, without reading current state. This includes at least:
- required-field presence (
nullable: false) - property type compatibility (the casts currently in
createEvent,EdgeBulkMutationRequest.kt:19-30) - source/target type compatibility
On failure, return 400 Bad Request and do not publish to the WAL. State-dependent checks (version conflict, uniqueness, referential integrity) stay in the RMW path.
Part 2 (nice-to-have — deferred to a follow-up PR) — Surface validation failures as HTTP errors.
Even after Part 1, invalid WALs may exist (legacy entries, schema changes post-publication). Two options:
- Option A (recommended): Replace the catch-all
onErrorResumeatMutationService.kt:66-68with a discriminating handler — payload-validation errors propagate as400 Bad Request; transient/infrastructure failures stay as per-itemERROR. Aligns with Part 1 and standard HTTP retry semantics. - Option B: Add a structured
errorCodefield (e.g.,"SCHEMA_VALIDATION") toMutationResult. Backward-compatible, but keeps the HTTP 200 / domain failure mismatch.
Alternatives Considered
- Validate in the async processor and propagate via a status channel — adds complexity, still wastes WAL capacity, doesn't fix the misleading
"QUEUED"response. - Force synchronous mode for all writes — defeats async throughput goals and doesn't fix Problem 2.
Additional Context
Observed in production: clients of an async edge table received "QUEUED" for invalid payloads. The downstream processor's synchronous retry got 200 OK + status:"ERROR", causing ambiguous retry classification. Failure had to be correlated manually from processor logs.
Activity
eazyhozy commentedon Jun 2, 2026
@em3s Updated the issue to clarify scope: the goal is to fail-fast all non-retryable bad requests before WAL publication, not just
nullablechecks.Concretely, Part 1 now covers every payload-deterministic constraint — required-field presence, property type compatibility, and source/target type compatibility (the casts already in
createEvent). State-dependent checks (version conflict, uniqueness, etc.) remain out of scope since they can't be validated before the WAL.No change to the Part 1 / Part 2 structure otherwise. PTAL when you have a moment.
em3s commentedon Jun 2, 2026
Looks good! Feel free to move forward with this. @eazyhozy
eazyhozy commentedon Jun 2, 2026
Scoping #371 down to Part 1 only (payload-deterministic validation before WAL publication, fail-fast 400, including the all-or-nothing barrier for bulk requests). Part 2 — surfacing RMW-stage validation failures as HTTP 400 instead of
200 + status:ERRORvia a discriminatingonErrorResume— is a nice-to-have and will be addressed in a separate follow-up PR.