Amplify-js: AWSPinpointProvider error when executing GraphQL operations on project without Analytics category

Created on 19 Jun 2019  路  10Comments  路  Source: aws-amplify/amplify-js

There seems to be changes introduced in aws-amplify that causes AWS PinPoint code to execute when doing GraphQL operations even though Analytics is not added to the Amplify project.

The error happens when executing GraphQL operations server side (TypeScript)

Error: No credentials, applicationId or region

    at AWSPinpointProvider.<anonymous> (C:\Users\meiri\dev\betterbook\betterbook-backend\node_modules\@aws-amplify\analytics\src\Providers\AWSPinpointProvider.ts:159:36)
    at step (C:\Users\meiri\dev\betterbook\betterbook-backend\node_modules\@aws-amplify\analytics\lib\Providers\AWSPinpointProvider.js:40:23)
    at Object.next (C:\Users\meiri\dev\betterbook\betterbook-backend\node_modules\@aws-amplify\analytics\lib\Providers\AWSPinpointProvider.js:21:53)
    at fulfilled (C:\Users\meiri\dev\betterbook\betterbook-backend\node_modules\@aws-amplify\analytics\lib\Providers\AWSPinpointProvider.js:12:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)

This started happening after upgrading my project to the latest versions, although I'm not sure which package causes the issue. (This also relates to #3486 that happens after the version upgrade, I added the workaround polyfill as suggested there and now this happens.

Environment:

node 10.16.0
amplify 1.7.4

"dependencies": {
    "@aws/dynamodb-batch-iterator": "^0.7.1",
    "@sentry/browser": "^5.4.0",
    "@sentry/node": "4.4.2",
    "@types/aws-lambda": "^8.10.27",
    "@types/babel__traverse": "^7.0.7",
    "@types/yargs": "^13.0.0",
    "amazon-cognito-auth-js": "^1.3.2",
    "amazon-cognito-identity-js": "^3.0.12",
    "apollo-cache-inmemory": "^1.6.2",
    "aws-amplify": "^1.1.29",
    "aws-appsync": "^1.8.0",
    "aws-lambda-multipart-parser": "^0.1.3",
    "aws-sdk": "^2.474.0",
    "aws4": "^1.8.0",
    "axios": "^0.18.1",
    "axios-es6": "^0.11.1",
    "bcrypt-nodejs": "^0.0.3",
    "blueimp-md5": "^2.10.0",
    "body-parser": "^1.19.0",
    "cryptr": "^4.0.2",
    "errorhandler": "^1.5.1",
    "es6-promise": "^4.2.8",
    "form-data": "^2.3.2",
    "google-libphonenumber": "^3.2.2",
    "graphql-tag": "^2.10.1",
    "handlebars": "^4.1.2",
    "isomorphic-fetch": "^2.2.1",
    "jsonwebtoken": "^8.5.1",
    "jwk-to-pem": "^2.0.1",
    "lodash": "^4.17.11",
    "node-cmd": "^3.0.0",
    "node-fetch": "^2.6.0",
    "node-jose": "^1.1.3",
    "qs": "^6.7.0",
    "request": "^2.88.0",
    "tabletop": "^1.5.2",
    "uuid": "^3.3.2",
    "ws": "^7.0.0"
  },
Analytics GraphQL to-be-reproduced

Most helpful comment

When using AWS Amplify CLI (or MobileHub), the configuration is contained in the auto-generated aws-exports.js.

Seeing these PinPoint issues re-appearing from time to time, maybe Amplify-CLI could add the Analytics: { disabled: true } iff the CLI has not added the Analytics service.

In the meantime,

import awsExports from './aws-exports';
Amplify.configure({
   ...awsExports,
   Analytics: { 
       disabled: true
   }
});

All 10 comments

Me too, for GraphQL api with JavaScript...

Me too, for REST with JavaScript, after upgrading to amplify ver 1.7.4

  Amplify.configure({
    Auth: {
      region: config.region,
      userPoolId: config.userPoolId,
      userPoolWebClientId: config.userPoolWebClientId,
      authenticationFlowType: 'USER_PASSWORD_AUTH'
    },
    Analytics: {
      disabled: true
    }
  })

Fixes the issue.

Me too, for REST with JavaScript, after upgrading to amplify ver 1.7.4

I'm seeing the same thing after upgrading. Our application doesn't use Analytics. My Amplify configure command is using the aws-exports.js file so the @aehmt fix doesn't fit my case.

When using AWS Amplify CLI (or MobileHub), the configuration is contained in the auto-generated aws-exports.js.

Seeing these PinPoint issues re-appearing from time to time, maybe Amplify-CLI could add the Analytics: { disabled: true } iff the CLI has not added the Analytics service.

In the meantime,

import awsExports from './aws-exports';
Amplify.configure({
   ...awsExports,
   Analytics: { 
       disabled: true
   }
});

Adding @leantide fix did the trick for me.

Thanks @leantide also fix the issue for me

Thanks @leantide!

This error message should no longer fire after this PR was merged: https://github.com/aws-amplify/amplify-js/pull/3614

I am going to close this issue per the fix above. Please open a new issue if there are any related problems.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

romainquellec picture romainquellec  路  3Comments

guanzo picture guanzo  路  3Comments

cosmosof picture cosmosof  路  3Comments

josoroma picture josoroma  路  3Comments

shinnapatthesix picture shinnapatthesix  路  3Comments