dashboard-plugin icon indicating copy to clipboard operation
dashboard-plugin copied to clipboard

Cannot read property 'X-Amzn-Trace-Id' of null - Testing Serverless Framework Pro wrapped Lambda function in API Gateway Console

Open serverlessguru opened this issue 5 years ago • 3 comments

Bug Report

Description

Cannot read property 'X-Amzn-Trace-Id' of null. This is caused by testing a Serverless Framework Pro wrapped Lambda function in API Gateway Console.

  1. What did you do? Deployed serverless framework API with single lambda function using the Serverless Framework Pro integration.
  2. What happened? All resources deployed properly. When testing the function in the API gateway console, it broke with the following error:
{
    "errorType": "TypeError",
    "errorMessage": "Cannot read property 'X-Amzn-Trace-Id' of null",
    "stack": [
        "TypeError: Cannot read property 'X-Amzn-Trace-Id' of null",
        "    at Runtime.handler (/var/task/serverless_sdk/index.js:9:87215)",
        "    at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"
    ]
}
  1. What should've happened? It should not require that attribute if the API Gateway console doesn't support it, in their test request.
  2. What's the content of your serverless.yml file?
org: xxxxx
app: xxxxxxxx
service: xxxxxx-auth-api
provider:
  name: aws
  runtime: nodejs12.x
  stage: ${opt:stage, "dev"}
  region: ${opt:region, "us-west-2"}
  profile: ${opt:profile, "xxxxxxxx"}
functions:
  test:
    name: ${self:custom.base}-test
    handler: index.handler
    events:
      - http:
          path: /test
          method: ANY
          cors: true
custom:
  base: ${self:service}-${self:provider.stage}

# https://serverless.com/framework/docs/dashboard/output-variables/
outputs:
  ApiEndpoint:
    Fn::Join:
      - ''
      - - https://
        - Ref: ApiGatewayRestApi
        - .execute-api.${self:provider.region}.amazonaws.com/${self:provider.stage}
  ApiId:
    Ref: ApiGatewayRestApi
  ApiResourceId:
    Fn::GetAtt:
    - ApiGatewayRestApi
    - RootResourceId

serverlessguru avatar Dec 16 '19 00:12 serverlessguru

This is caused by testing a Serverless Framework Pro wrapped Lambda function in API Gateway Console.

Can you share more details on that?

Was it tested in Lambda console (by pressing "Test" button), if so, then what event object you've used?

If it was tested in API Gateway console, do you mean that you've clicked API url, and that resulted with such error?

medikoo avatar Dec 23 '19 14:12 medikoo

Remove "app" and "org" labels for serverless.yml

PabloRN avatar Jan 07 '20 09:01 PabloRN

Remove "app" and "org" labels for serverless.yml

If you do this, Github deploy triggers won't work.

ddamato avatar Mar 08 '20 14:03 ddamato