aws-amplify / amplify-backend

Home to all tools related to Amplify's code-first DX (Gen 2) for building fullstack apps on AWS
Apache License 2.0
184 stars 62 forks source link

Propagate errors to AppSync #2162

Closed sobolk closed 2 weeks ago

sobolk commented 2 weeks ago

Problem

When errors are thrown in Lambda they are not propagated to upstream AppSync instance.

This is due to asynchronous dispatch from AppSync to Lambda.

Changes

The changes in this PR are to catch and forward as many errors as possible.

  1. Add section in conversation turn executor that attempts to send error back to AppSync in a form of mutation (this is best effort as communication to AppSync might be impaired as well).
  2. Refactor conversation turn executor's initialization logic to make it lazy. So that validation errors from that phase are captured and sent to AppSync as well.
  3. Adjusted tests and e2e mock schemas to accommodate extra errors field.

Validation

  1. Added tests (unit and e2e)
  2. Manual validation with upstream.

Screenshot from e2e testing with AppSync using snapshot release: image

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

changeset-bot[bot] commented 2 weeks ago

🦋 Changeset detected

Latest commit: 4a7fd00a4fdfee6fe83f4d003d9fb2e435fd58c0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages | Name | Type | | -------------------------- | ----- | | @aws-amplify/ai-constructs | Minor | | @aws-amplify/backend-ai | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR