Skip to content
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

[Sam Local start api] Error 500 on _X_AMZN_TRACE_ID missing since upgrading to 1.0 #2137

Closed
matdumsa opened this issue Jul 28, 2020 · 3 comments

Comments

@matdumsa
Copy link
Contributor

Description

Since upgrading to Sam 1.0.0 my local start api command is failing each NodeJS lambda request that's using X-ray, this was not a problem before

Steps to reproduce

running sam local start-api -p 3000 -t template.yaml -s packages/website/build

const AWSXRay = require('aws-xray-sdk-core');
const aws = AWSXRay.captureAWS(require('aws-sdk'));
const s3 = new aws.S3();

Observed result

Expected _X_AMZN_TRACE_ID to be set.\n at Object.contextMissingRuntimeError [as contextMissing] (/var/task/node_modules/aws-xray-sdk-core/lib/context_utils.js:21:15)\n at Segment.resolveLambdaTraceData (/var/task/node_modules/aws-xray-sdk-core/lib/env/aws_lambda.js:93:43)\n at Object.getSegment (/var/task/node_modules/aws-xray-sdk-core/lib/context_utils.js:94:17)\n at Object.resolveSegment (/var/task/node_modules/aws-xray-sdk-core/lib/context_utils.js:73:19)\n at features.constructor.captureAWSRequest [as customRequestHandler] (/var/task/node_modules/aws-xray-sdk-core/lib/patchers/aws_p.js:66:29)\n at features.constructor.addAllRequestListeners (/var/task/node_modules/aws-sdk/lib/service.js:283:12)\n at features.constructor.makeRequest (/var/task/node_modules/aws-sdk/lib/service.js:203:10)\n at features.constructor.svc. [as getObject] (/var/task/node_modules/aws-sdk/lib/service.js:677:23)

Expected result

Works as in the past

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: OS X Catalina 10.15.6 (19G73)
  2. sam --version: 1.0.0

Could be mitigated by adding _X_AMZN_TRACE_ID: 1234 to my template.yaml Api Env Var section

@matdumsa
Copy link
Contributor Author

matdumsa commented Feb 4, 2021

Found a work around,

Add this to your YAML

Globals:
    Function:
        Environment:
            Variables:
                AWS_XRAY_CONTEXT_MISSING: LOG_ERROR
                AWS_XRAY_LOG_LEVEL: silent

@jfuss
Copy link
Contributor

jfuss commented Feb 8, 2023

This looks like a duplicate of #217. I am going to close this in favor of that one.

@jfuss jfuss closed this as completed Feb 8, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Feb 8, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants