Skip to content

fix(event-handler): fail invocation on UnauthorizedException in onPublish - #5621

Open
svozza wants to merge 3 commits into
mainfrom
fix/appsync-events-unauthorized-non-aggregate
Open

fix(event-handler): fail invocation on UnauthorizedException in onPublish#5621
svozza wants to merge 3 commits into
mainfrom
fix/appsync-events-unauthorized-non-aggregate

Conversation

@svozza

@svozza svozza commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

UnauthorizedException thrown from a non-aggregate onPublish handler was caught per event and returned as an { id, error } entry, so the invocation completed successfully. The documented behaviour, and the existing behaviour for aggregate onPublish and onSubscribe handlers, is for the invocation to fail. This change aligns the non-aggregate path with the other two.

Changes

  • AppSyncEventsResolver.handleOnPublish rethrows UnauthorizedException inside the per-event catch before formatting the error response, matching the aggregate and subscribe paths
  • Router.onPublish JSDoc notes that UnauthorizedException is the exception to the per-event error handling
  • Adds a unit test covering a non-aggregate onPublish handler that throws UnauthorizedException for one of two events, asserting the invocation rejects

Issue number: closes #5620


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M PR between 30-99 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: UnauthorizedException in a non-aggregate onPublish handler does not fail the invocation

2 participants