Repository navigation
fix: raise invoke errors in the typedErrors pipeline function - #390
Merged
Merged
Conversation
With `typedErrors: true`, an untyped error thrown by a resolver handler was silently swallowed. createAppSyncHandler rethrows untyped errors, so the Lambda invocation fails and AppSync puts the failure into the pipeline function's `ctx.error`. The function's response handler returned `ctx.result` without raising it, so AppSync dropped the error and the field resolved to `null` with no GraphQL error and HTTP 200. Clients could not tell a failed mutation from an empty result. The resolver-level `if (ctx.error) util.appendError(...)` branch could not catch this: an error left in a pipeline function's `ctx.error` never reaches the resolver's `ctx.error`. Typed errors (the `__appSyncError` envelope) were not affected. Changes: - The pipeline function now calls `util.error(ctx.error.message, ctx.error.type)`, which reports the same message and `Lambda:Unhandled` type a UNIT direct-Lambda resolver does. - Remove the dead `ctx.error` branch from the resolver response handler. - Correct the `typedErrors` prop doc and llm.md: without the flag the Lambda gets no `APPSYNC_TYPED_ERRORS`, so typed errors rethrow and surface as `Lambda:Unhandled`, not as envelope field data. - Add tests that execute the synthesized inline handlers with a fake `util`, covering invoke errors, typed envelopes and pass-through results. The invoke-error test fails against the previous handler. Verified the new function handler with AppSync `EvaluateCode` on the APPSYNC_JS 1.0.0 runtime: an unhandled Lambda error is raised, a successful result passes through unchanged. Deploying this changes the inline code of every typedErrors pipeline function; the resolver topology and logical IDs are unchanged.
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
typedErrors: true, an untyped error thrown by a resolver handler wassilently swallowed. createAppSyncHandler rethrows untyped errors, so the
Lambda invocation fails and AppSync puts the failure into the pipeline
function's
ctx.error. The function's response handler returnedctx.resultwithout raising it, so AppSync dropped the error and the fieldresolved to
nullwith no GraphQL error and HTTP 200. Clients could nottell a failed mutation from an empty result.
The resolver-level
if (ctx.error) util.appendError(...)branch could notcatch this: an error left in a pipeline function's
ctx.errorneverreaches the resolver's
ctx.error. Typed errors (the__appSyncErrorenvelope) were not affected.
Changes:
util.error(ctx.error.message, ctx.error.type),which reports the same message and
Lambda:Unhandledtype a UNITdirect-Lambda resolver does.
ctx.errorbranch from the resolver response handler.typedErrorsprop doc and llm.md: without the flag theLambda gets no
APPSYNC_TYPED_ERRORS, so typed errors rethrow and surfaceas
Lambda:Unhandled, not as envelope field data.util, covering invoke errors, typed envelopes and pass-through results.The invoke-error test fails against the previous handler.
Verified the new function handler with AppSync
EvaluateCodeon theAPPSYNC_JS 1.0.0 runtime: an unhandled Lambda error is raised, a
successful result passes through unchanged.
Deploying this changes the inline code of every typedErrors pipeline
function; the resolver topology and logical IDs are unchanged.