Getting error when using local amplify mock api: The request has a 'X-Amzn-Trace-Id' HTTP header which is reserved for AWS X-Ray trace header

0

I am currently using Amplify to set up my backend because Appsync is a key part of my stack.

However, I also use SQS to publish certain messages into a queue. This is easily done using the in-code editor of lambda but since I'm running lambda functions locally now, I am unable to send messages to the queue now with the following error:

InvalidParameterValue: The request has a 'X-Amzn-Trace-Id' HTTP header which is reserved for AWS X-Ray trace header and has an invalid value 'amplify-mock-x-amzn-trace-id'

This is my code to send messages into the queue.

response = await sqs.sendMessageBatch(slackParams).promise().catch(async (err) => { console.log(response from sqs: ${err}); });

Once I do amplify push, the code works fine on the cloud lambda but the issue comes only when I do amplify mock api. (During local testing, I am unable to add to the queue)

Is there any way I can mock my SQS setup locally as well? Any help is appreciated!

1 回答
0

Hi,

Is this InvalidParameterValue error coming from SQS? Looks like the issue stems from Amplify setting the 'X-Amzn-Trace-Id' to 'amplify-mock-x-amzn-trace-id', which may be an improper format when you send to SQS. Could you try removing the 'X-Amzn-Trace-Id' in the request for these tests if you aren't interested in tracing during testing?

AWS
Jon_L
已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则