aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.4k stars 2.11k forks source link

Amplify Cognito PostConfirmation trigger default code (callback doesn't exists) showing an error. #9060

Closed idobleicher closed 1 year ago

idobleicher commented 2 years ago

Before opening, please confirm:

JavaScript Framework

Angular

Amplify APIs

Authentication

Amplify Categories

auth

Environment information

``` # Put output below this line System: OS: Windows 10 10.0.19043 CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz Memory: 17.06 GB / 31.94 GB Binaries: Node: 15.14.0 - D:\apps\node\node.EXE npm: 7.7.6 - D:\apps\node\npm.CMD Browsers: Chrome: 94.0.4606.81 Edge: Spartan (44.19041.1266.0), Chromium (94.0.992.50) Internet Explorer: 11.0.19041.1202 npmPackages: @angular-devkit/build-angular: ~12.2.3 => 12.2.6 @angular/animations: ~12.2.3 => 12.2.7 @angular/animations/browser: undefined () @angular/animations/browser/testing: undefined () @angular/cdk: ^12.2.3 => 12.2.6 @angular/cdk/a11y: undefined () @angular/cdk/accordion: undefined () @angular/cdk/bidi: undefined () @angular/cdk/clipboard: undefined () @angular/cdk/coercion: undefined () @angular/cdk/collections: undefined () @angular/cdk/drag-drop: undefined () @angular/cdk/keycodes: undefined () @angular/cdk/layout: undefined () @angular/cdk/observers: undefined () @angular/cdk/overlay: undefined () @angular/cdk/platform: undefined () @angular/cdk/portal: undefined () @angular/cdk/scrolling: undefined () @angular/cdk/stepper: undefined () @angular/cdk/table: undefined () @angular/cdk/testing: undefined () @angular/cdk/testing/protractor: undefined () @angular/cdk/testing/selenium-webdriver: undefined () @angular/cdk/testing/testbed: undefined () @angular/cdk/text-field: undefined () @angular/cdk/tree: undefined () @angular/cli: ~12.2.3 => 12.2.6 @angular/common: ~12.2.3 => 12.2.7 @angular/common/http: undefined () @angular/common/http/testing: undefined () @angular/common/testing: undefined () @angular/common/upgrade: undefined () @angular/compiler: ~12.2.3 => 12.2.7 @angular/compiler-cli: ~12.2.3 => 12.2.7 @angular/compiler/testing: undefined () @angular/core: ~12.2.3 => 12.2.7 @angular/core/testing: undefined () @angular/forms: ~12.2.3 => 12.2.7 @angular/google-maps: ^12.2.3 => 12.2.6 @angular/localize: ~12.2.3 => 12.2.7 @angular/localize/init: undefined () @angular/material: ^12.2.3 => 12.2.6 @angular/material/autocomplete: undefined () @angular/material/autocomplete/testing: undefined () @angular/material/badge: undefined () @angular/material/badge/testing: undefined () @angular/material/bottom-sheet: undefined () @angular/material/bottom-sheet/testing: undefined () @angular/material/button: undefined () @angular/material/button-toggle: undefined () @angular/material/button-toggle/testing: undefined () @angular/material/button/testing: undefined () @angular/material/card: undefined () @angular/material/card/testing: undefined () @angular/material/checkbox: undefined () @angular/material/checkbox/testing: undefined () @angular/material/chips: undefined () @angular/material/chips/testing: undefined () @angular/material/core: undefined () @angular/material/core/testing: undefined () @angular/material/datepicker: undefined () @angular/material/datepicker/testing: undefined () @angular/material/dialog: undefined () @angular/material/dialog/testing: undefined () @angular/material/divider: undefined () @angular/material/divider/testing: undefined () @angular/material/expansion: undefined () @angular/material/expansion/testing: undefined () @angular/material/form-field: undefined () @angular/material/form-field/testing: undefined () @angular/material/form-field/testing/control: undefined () @angular/material/grid-list: undefined () @angular/material/grid-list/testing: undefined () @angular/material/icon: undefined () @angular/material/icon/testing: undefined () @angular/material/input: undefined () @angular/material/input/testing: undefined () @angular/material/list: undefined () @angular/material/list/testing: undefined () @angular/material/menu: undefined () @angular/material/menu/testing: undefined () @angular/material/paginator: undefined () @angular/material/paginator/testing: undefined () @angular/material/progress-bar: undefined () @angular/material/progress-bar/testing: undefined () @angular/material/progress-spinner: undefined () @angular/material/progress-spinner/testing: undefined () @angular/material/radio: undefined () @angular/material/radio/testing: undefined () @angular/material/select: undefined () @angular/material/select/testing: undefined () @angular/material/sidenav: undefined () @angular/material/sidenav/testing: undefined () @angular/material/slide-toggle: undefined () @angular/material/slide-toggle/testing: undefined () @angular/material/slider: undefined () @angular/material/slider/testing: undefined () @angular/material/snack-bar: undefined () @angular/material/snack-bar/testing: undefined () @angular/material/sort: undefined () @angular/material/sort/testing: undefined () @angular/material/stepper: undefined () @angular/material/stepper/testing: undefined () @angular/material/table: undefined () @angular/material/table/testing: undefined () @angular/material/tabs: undefined () @angular/material/tabs/testing: undefined () @angular/material/toolbar: undefined () @angular/material/toolbar/testing: undefined () @angular/material/tooltip: undefined () @angular/material/tooltip/testing: undefined () @angular/material/tree: undefined () @angular/material/tree/testing: undefined () @angular/platform-browser: ~12.2.3 => 12.2.7 @angular/platform-browser-dynamic: ~12.2.3 => 12.2.7 @angular/platform-browser-dynamic/testing: undefined () @angular/platform-browser/animations: undefined () @angular/platform-browser/testing: undefined () @angular/router: ~12.2.3 => 12.2.7 @angular/router/testing: undefined () @angular/router/upgrade: undefined () @aws-amplify/ui-angular: ^1.0.25 => 1.0.25 @datorama/akita: ^6.1.3 => 6.2.3 @datorama/akita-ng-effects: ^1.0.1 => 1.0.5 @datorama/akita-ngdevtools: ^3.0.2 => 3.0.2 @deck.gl/core: ^8.3.15 => 8.5.9 @deck.gl/google-maps: ^8.3.15 => 8.5.9 @deck.gl/layers: ^8.3.15 => 8.5.9 @ng-bootstrap/ng-bootstrap: ^10.0.0 => 10.0.0 @ng-select/ng-select: ^7.3.0 => 7.3.0 @percy/cli: ^1.0.0-beta.42 => 1.0.0-beta.68 @percy/cypress: ^3.1.0 => 3.1.1 @percy/protractor: ^1.1.0 => 1.1.0 @sentry/angular: ^6.2.5 => 6.13.2 @sentry/tracing: ^6.2.5 => 6.13.2 @skyline-ai/skylo-core: ^0.1.344 => 0.1.347 @turf/circle: ^6.3.0 => 6.5.0 @turf/helpers: ^6.3.0 => 6.5.0 @types/jasmine: ^3.6.6 => 3.9.1 @types/jasminewd2: ^2.0.8 => 2.0.10 @types/lodash-es: ^4.17.4 => 4.17.5 @types/mixpanel-browser: ^2.35.7 => 2.35.7 @types/node: ^12.19.15 => 12.20.26 (14.17.18) @types/selenium-webdriver: ^4.0.11 => 4.0.15 (3.0.19) ag-grid-angular: ^26.0.0 => 26.0.0 ag-grid-base-icons: 1.0.0 ag-grid-community: ^26.0.0 => 26.0.0 ag-grid-enterprise: ^26.0.0 => 26.0.1 angular-animations: ^0.11.0 => 0.11.0 aws-amplify: 3.3.18 => 3.3.18 bootstrap: ^4.6.0 => 4.6.0 chromedriver: ^88.0.0 => 88.0.0 codelyzer: ^6.0.0 => 6.0.2 cypress: ^7.7.0 => 7.7.0 example-typescript: 1.0.0 fuzzy-search: ^3.2.1 => 3.2.1 generate-password-browser: ^1.0.3 => 1.1.0 highcharts: ^9.1.2 => 9.2.2 highcharts-angular: ^2.9.0 => 2.10.0 jasmine: ^3.6.4 => 3.9.0 (2.8.0) jasmine-core: ^3.6.0 => 3.9.0 (2.8.0) jasmine-spec-reporter: ^6.0.0 => 6.0.0 jstat: ^1.9.4 => 1.9.5 karma: ^6.1.1 => 6.3.4 karma-chrome-launcher: ^3.1.0 => 3.1.0 karma-coverage-istanbul-reporter: ^3.0.3 => 3.0.3 karma-jasmine: ^4.0.1 => 4.0.1 karma-jasmine-html-reporter: ^1.5.4 => 1.7.0 lib: 0.0.1 lodash-es: ^4.17.20 => 4.17.21 logrocket: ^1.0.14 => 1.3.0 mixpanel-browser: ^2.41.0 => 2.41.0 moment: ^2.29.1 => 2.29.1 moment-range: ^4.0.2 => 4.0.2 ng2-nouislider: ^1.8.3 => 1.8.3 ngx-clipboard: ^14.0.1 => 14.0.1 ngx-highlightjs: ^5.0.0 => 5.0.0 ngx-highlightjs/plus: undefined () ngx-moment: ^5.0.0 => 5.0.0 node-example: 1.0.0 nouislider: ^15.4.0 => 15.4.0 placeholder-loading: ^0.2.6 => 0.2.6 protractor: ^7.0.0 => 7.0.0 protractor-example: 1.0.0 ramda: ^0.27.1 => 0.27.1 rxjs: ~6.6.7 => 6.6.7 (6.4.0, 7.3.0) rxjs/ajax: undefined () rxjs/fetch: undefined () rxjs/internal-compatibility: undefined () rxjs/operators: undefined () rxjs/testing: undefined () rxjs/webSocket: undefined () ts-node: ~8.3.0 => 8.3.0 tslib: ^2.0.0 => 2.3.1 (2.3.0, 1.14.1, 2.1.0) tslint: ~6.1.0 => 6.1.3 typescript: ~4.3.5 => 4.3.5 (3.9.10) typescript-example: 1.0.0 uuid: ^8.3.2 => 8.3.2 (3.4.0, 3.3.2) webpack-bundle-analyzer: ^4.4.0 => 4.4.2 zone-mix: undefined () zone-node: undefined () zone-testing: undefined () zone.js: ~0.11.4 => 0.11.4 (0.10.3) zone.js/async-test: undefined () zone.js/async-test.min: undefined () zone.js/fake-async-test: undefined () zone.js/fake-async-test.min: undefined () zone.js/jasmine-patch: undefined () zone.js/jasmine-patch.min: undefined () zone.js/long-stack-trace-zone: undefined () zone.js/long-stack-trace-zone.min: undefined () zone.js/mocha-patch: undefined () zone.js/mocha-patch.min: undefined () zone.js/proxy: undefined () zone.js/proxy.min: undefined () zone.js/sync-test: undefined () zone.js/sync-test.min: undefined () zone.js/task-tracking: undefined () zone.js/task-tracking.min: undefined () zone.js/webapis-media-query: undefined () zone.js/webapis-media-query.min: undefined () zone.js/webapis-notification: undefined () zone.js/webapis-notification.min: undefined () zone.js/webapis-rtc-peer-connection: undefined () zone.js/webapis-rtc-peer-connection.min: undefined () zone.js/webapis-shadydom: undefined () zone.js/webapis-shadydom.min: undefined () zone.js/wtf: undefined () zone.js/wtf.min: undefined () zone.js/zone-bluebird: undefined () zone.js/zone-bluebird.min: undefined () zone.js/zone-error: undefined () zone.js/zone-error.min: undefined () zone.js/zone-legacy: undefined () zone.js/zone-legacy.min: undefined () zone.js/zone-patch-canvas: undefined () zone.js/zone-patch-canvas.min: undefined () zone.js/zone-patch-cordova: undefined () zone.js/zone-patch-cordova.min: undefined () zone.js/zone-patch-electron: undefined () zone.js/zone-patch-electron.min: undefined () zone.js/zone-patch-fetch: undefined () zone.js/zone-patch-fetch.min: undefined () zone.js/zone-patch-jsonp: undefined () zone.js/zone-patch-jsonp.min: undefined () zone.js/zone-patch-message-port: undefined () zone.js/zone-patch-message-port.min: undefined () zone.js/zone-patch-promise-test: undefined () zone.js/zone-patch-promise-test.min: undefined () zone.js/zone-patch-resize-observer: undefined () zone.js/zone-patch-resize-observer.min: undefined () zone.js/zone-patch-rxjs: undefined () zone.js/zone-patch-rxjs-fake-async: undefined () zone.js/zone-patch-rxjs-fake-async.min: undefined () zone.js/zone-patch-rxjs.min: undefined () zone.js/zone-patch-socket-io: undefined () zone.js/zone-patch-socket-io.min: undefined () zone.js/zone-patch-user-media: undefined () zone.js/zone-patch-user-media.min: undefined () npmGlobalPackages: @aws-amplify/cli: 6.3.1 @skyline-ai/skylo-core: 0.0.0-watch+1634212562044 grunt: 1.4.1 mine: 0.1.0 npm: 7.7.6 rimraf: 3.0.2 serverless: 2.45.2 ```

Describe the bug

When adding a trigger via the auth flow, trigger name: post-confirmation. The default code is calling the event with a callback.

but the callback itself is undefined. which causes an error.

exports.handler = (event, context, callback) => { // insert code to be executed by your lambda trigger callback(null, event); };

callback(null, event) -- here is the error.

Expected behavior

Why is there a callback? if it's undefined. Maybe to remove it? or maybe to tell what to do with it image

Reproduction steps

  1. Add amplify auth
  2. Enable Cognito trigger post confirmation
  3. Adding a user in the website (AdminCognito, or from the Cognito itself... is not triggering the post-confirmation) and you have it :)

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

nadetastic commented 1 year ago

Hi @iuyt9003

Following up on this - if you are still facing this problem, you can remove the callback method from your function. However, since the underlying function is a Lambda, removing the call back requires you to update the handler from a Non-Async handler to an Async handler

Also, please note that the default generated handler was updated in the past to be an async handler by default.