question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trying to trigger AppSync query via lambda function. V4 signer.addauthorization not working. Error message: "Data must be a string or a buffer"

See original GitHub issue

Error Message 2018-11-23T14:37:03.533Z 3e0ff525-ef2d-11e8-8328-89b33f69a07f TypeError: Data must be a string or a buffer at Hmac.update (crypto.js:99:16) at Object.hmac (/var/task/node_modules/aws-sdk/lib/util.js:399:50) at Object.getSigningKey (/var/task/node_modules/aws-sdk/lib/signers/v4_credentials.js:74:35) at V4.signature (/var/task/node_modules/aws-sdk/lib/signers/v4.js:98:36) at V4.authorization (/var/task/node_modules/aws-sdk/lib/signers/v4.js:93:36) at V4.addAuthorization (/var/task/node_modules/aws-sdk/lib/signers/v4.js:35:12) at AWS.config.credentials.get.err (/var/task/index.js:52:10) at Credentials.get (/var/task/node_modules/aws-sdk/lib/credentials.js:126:7) at exports.handler (/var/task/index.js:42:25) END RequestId: 3e0ff525-ef2d-11e8-8328-89b33f69a07f REPORT RequestId: 3e0ff525-ef2d-11e8-8328-89b33f69a07f Duration: 103.19 ms Billed Duration: 200 ms Memory Size: 128 MB Max Memory Used: 60 MB RequestId: 3e0ff525-ef2d-11e8-8328-89b33f69a07f Process exited before completing request

Expected result The V4 signing should complete successfully.

Current result it currently fails with the error message above. I did some digging, in the hmac function in util.js, and realized that it gets called 3 times while the lambda function runs. I only call signer.addAuthorization(cred, date) once.

the first 2 times hmac gets called, it has a correct string parameter, which allows the successful creation of a buffer used in the function to create a new hmac, and return it.

the third time, this string parameter is false. Thus, the Buffer isn’t created, and the hmac.update(string) function fails with the error indicated above.

any help? Could this be a result of something I’m doing wrong?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
nireakcommented, Mar 10, 2019

In case it helps somebody…I had the same problem and the origin of it was that the region environment variable was empty ( I was typing env.REGION when mine was defined in lowercase: env.region)

1reaction
hagiosoforicommented, Nov 26, 2018

lambda runtime Node 8.10

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tutorial: Lambda resolvers - AWS AppSync
In this section, we'll show you how to write a Lambda function that performs business logic based on the invocation of a GraphQL...
Read more >
Step by step guide to integrate Gatsby project with AWS ...
Useful link for me to setup a Gatsby project. Install gatsby plugin — gatsby-plugin-aws-elasticsearch (Step 2). First, install the package using npm or...
Read more >
Functions - Exporting AppSync operations to a Lambda layer ...
When you need to call your AppSync API from a Lambda function, you can export your AppSync operations generated by Amplify to a...
Read more >
AWS Lambda function unable to access AppSync GraphQL API
The problem started after installed - amplify cli "4.45.2". The old code for autogenerated permissions in the lambda cloudformation template ...
Read more >
Backend GraphQL: How to trigger an AWS AppSync mutation ...
A developer can define an AWS Lambda function that is triggered ... ID must always start with the string CognitoUserPool if you want...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found