Skip to content

Bug: AppSync events onSubscribe resolver return type should be ignored #3884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dreamorosi opened this issue May 2, 2025 · 2 comments · Fixed by #3888
Closed

Bug: AppSync events onSubscribe resolver return type should be ignored #3884

dreamorosi opened this issue May 2, 2025 · 2 comments · Fixed by #3888
Assignees
Labels
bug Something isn't working completed This item is complete and has been merged/shipped event-handler This item relates to the Event Handler Utility

Comments

@dreamorosi
Copy link
Contributor

Expected Behavior

When I create an onSubscribe handler using the AppSyncEventsResolver from the Event Handler utility I should not have to worry about mistakenly breaking subscriptions, if I leave a return statement in the handler.

Current Behavior

Whenever the onSubscribe handler returns something the subscription will fail with this error:

{
  "errorType": "HandlerExecutionError",
  "message": "Unable to process request"
}

Code snippet

import { Logger, LogLevel } from '@aws-lambda-powertools/logger';
import { AppSyncEventsResolver } from '@aws-lambda-powertools/event-handler/appsync-events';
import type { Context } from 'aws-lambda';

const logger = new Logger({
  serviceName: 'AppSyncEvents',
  logLevel: LogLevel.DEBUG,
});
const app = new AppSyncEventsResolver({ logger });

app.onSubscribe('/foo/*', (event) => {
  logger.debug('New subscription', { channel: event.info.channel.path });

  return true; // this should be ignored
});

export const handler = async (event: unknown, context: Context) =>
  app.resolve(event, context);

Steps to Reproduce

Deploy the code above, and try to subscribe to the foo/* channel.

Possible Solution

Similar to what Powertools for AWS Lambda (Python) does here, we should ignore the return of the onSubscribe handler.

Powertools for AWS Lambda (TypeScript) version

latest

AWS Lambda function runtime

22.x

Packaging format used

npm

Execution logs

@dreamorosi dreamorosi added bug Something isn't working confirmed The scope is clear, ready for implementation event-handler This item relates to the Event Handler Utility labels May 2, 2025
@dreamorosi dreamorosi self-assigned this May 2, 2025
@dreamorosi dreamorosi moved this from Triage to Working on it in Powertools for AWS Lambda (TypeScript) May 2, 2025
@github-project-automation github-project-automation bot moved this from Working on it to Coming soon in Powertools for AWS Lambda (TypeScript) May 5, 2025
Copy link
Contributor

github-actions bot commented May 5, 2025

⚠️ COMMENT VISIBILITY WARNING ⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot added pending-release This item has been merged and will be released soon and removed confirmed The scope is clear, ready for implementation labels May 5, 2025
Copy link
Contributor

github-actions bot commented May 6, 2025

This is now released under v2.19.1 version!

@github-actions github-actions bot added completed This item is complete and has been merged/shipped and removed pending-release This item has been merged and will be released soon labels May 6, 2025
@dreamorosi dreamorosi moved this from Coming soon to Shipped in Powertools for AWS Lambda (TypeScript) May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working completed This item is complete and has been merged/shipped event-handler This item relates to the Event Handler Utility
Projects
1 participant