ID |
|
|---|---|
Status |
Backlog |
Bucket |
bug |
Priority |
3 |
Theme |
runtime-connection |
Created |
2026-11-13 |
Updated |
2026-11-13 |
A @service nested-transaction failure that propagated to the router is reported once, not twice
Goal
On the owned-connection engine, a @service whose own transaction(...) / transactionResult(...) throws, with the exception propagating out of the service to ErrorRouter, gets one report for that one exception: a claimed @error payload with no top-level error beside it, or the router’s redacted or surfaced error alone. The fixed "A nested transaction in this field failed; the field’s writes were rolled back" error (NestedScopeFailedException) stays only for a nested failure the consumer’s code caught, which is the silent-rollback trap the report exists for. The field still rolls back either way. Today the named error is added beside every propagated nested failure too, so an ordinary validation error claimed into a payload reaches clients as a top-level error and logs at ERROR.
Reported by
The sis Graphitron 10 port (sis C46, RC47; the code is unchanged at trunk f6403c10a). 47 sis service classes behind 58 mutation fields wrap their writes in their own ctx.transaction(...) / transactionResult(...) and throw from inside the lambda (EndreKullService: throw ErrorMapper.mapError(e), FinnesIkkeException, IllegalArgumentException), and an @error handler claims the exception into the payload (UgyldigInput, FantIngenOppforingAaEndre). The response carries the typed payload and the named error; v9 answered with the payload alone. The rollback matches v9. 13 sis fsapi-rest ITs fail on the extra error alone. sis asked that no item be filed on its side.
Current behaviour
-
GraphitronTransactionProviderGenerator.markRollbackOnlyrecordsconsumerFailureandcauseon the outermost scope when jOOQ rolls a joined consumer scope back, before anything knows whether the exception will be caught or claimed. Only the first consumer failure’s cause is kept. -
MutationFieldScopeEmitter.settleFieldcomputescaught(the nested cause is not in the cause chain of any exception infield.handled) andreported, then theif (nestedFailed)arm returns aNestedScopeFailedExceptionunconditionally, ahead ofreturn reported ? null : cause. -
GraphitronConnectionInstrumentationGeneratoraddsErrorRouter.settleFailure(...)for it every time;caughtandfieldReportedonly pick the log message and whether the value is dropped (!nested.fieldReported() || errorUnder). -
markFieldFailedsetsfield.failedand appends tofield.handledin the same call, so!caughtimpliesreported: the condition sis proposes (nestedFailed && !caught && reported) reduces tonestedFailed && !caught. -
A failed generated scope already adds no second error, and a claimed generated failure keeps its payload with none (R1101’s
aGeneratedWriteWhoseFailureAnErrorChannelClaims_keepsItsPayload_andAddsNoNestedFailureReport). The proposal brings a propagated@servicefailure in line with that.
The decision this revisits
R1101 settled the opposite deliberately. Review round 4 made the named error stand beside the field’s other errors rather than be suppressed by them, motivated by PostgreSQL: a caught SQL failure aborts the transaction, the service’s next statement fails with 25P02, and that 25P02 is what reaches the router. Round 5 offered essentially this item’s rule ("add it only when the recorded nested cause is not in the cause chain of an exception the router handled") and the user chose instead to keep the report in both cases with wording true in both. The 25P02 case still computes caught == true under this item (the propagating exception is the 25P02, not the nested cause), so it keeps its report; what changes is only the case where the nested failure itself is what the router handled. The new evidence is the sis port’s volume (58 fields, 13 ITs) and the client-visible effect on claimed validation errors.
Fork to settle at Spec
-
Broad: suppress whenever the nested cause propagated (
!caught), whether the router claimed, redacted or surfaced it. One exception, one report; matches generated scopes. Changes the R1101 test pinning "uncaught: the router’s redacted error and the named one beside it". -
Narrow: suppress only when the exception was claimed into a payload.
settleFieldcannot tell a claim from a redaction today;field.handledwould have to carry that.
To check at Spec
-
Settle’s own
cause(a timed-out tenant, a scope left open) rides on the report as a suppressed exception today; falling through toreturn reported ? null : causedrops it. Decide deliberately. -
Value handling when
settleFieldreturnsnull: theelse if (errorUnder)arm must keep a claimed payload and null a redacted field, as!fieldReported || errorUnderdoes now. -
Exception identity: jOOQ rethrows a
RuntimeExceptionfromtransactionResultas is and wraps a checked one, so identity or the cause chain holds when the service throws inside the lambda. A service that catches outside the lambda and throws a mapped exception without chaining the original computescaught == trueand keeps the report; pin a sis-shaped case and state the boundary in the docs. -
A service that swallows nested failure A and later lets B propagate: only A is recorded, so
caughtholds and the report stays. Conservative, and should be pinned. -
If
NestedScopeFailedExceptionis then only ever built withcaught == true, its "propagated out of the field" message arm is dead: remove it and list it under Retired vocabulary. -
A
@serviceon a Query field: check whether a propagated nested failure reaches the client as a second error by another route. -
Docs and tests:
error-channel.adoc("beside any payload"), the owned-path transactions section ofruntime-extension-points.adoc,service.adoctransaction demarcation, the emitted javadoc inMutationFieldScopeEmitterand the class javadoc ofGraphitronConnectionInstrumentationGenerator, achangelog.mdline (consumer-visible), and the tests asserting the named error beside a claimed or redacted error (OwnedBuildSettleSurfaceTest,TenantScatterSubstrateTest, the sakila execution tests).