Skip to content

Bug: sam local start-api sets context variable requestTimeEpoch with seconds precision instead of milliseconds #8020

Open
@HaaLeo

Description

@HaaLeo

Description:

When executing sam local start-api command with an APIGateway and a Lambda Proxy Integration SAM injects a payload where the requestTimeEpoch context variable is injected as epoch seconds. However, according to the AWS documentation This value should be passed in with millisecond resolution

Steps to reproduce:

  1. Create a cloudformation template with an ApiGatewa + Lambda Proxy integration which logs the event.
  2. Start the API with sam local start-api
  3. Take a look at the logged event

Observed result:

The event contains requestTimeEpoch with unit seconds
Example event payload:

{
  // ... other properties
  "requestContext": {
    // ... other properties
    "requestTime": "13/May/2025:18:26:58 +0000",
    "requestTimeEpoch": 1747160818 
  }
}

Expected result:

The event contains requestTimeEpoch with unit milliseconds
Example event payload:

{
  // ... other properties
  "requestContext": {
    // ... other properties
    "requestTime": "13/May/2025:18:26:58 +0000",
    "requestTimeEpoch": 1747160818000 
  }
}

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

  1. OS: macOS-15.4.1-arm64-arm-64bit-Mach-O
  2. sam --version: SAM CLI, version 1.138.0
  3. AWS region: us-east-1
{
  "version": "1.138.0",
  "system": {
    "python": "3.13.3",
    "os": "macOS-15.4.1-arm64-arm-64bit-Mach-O"
  },
  "additional_dependencies": {
    "docker_engine": "28.1.1",
    "aws_cdk": "Not available",
    "terraform": "Not available"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_PACKAGE_PERFORMANCE",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}

Add --debug flag to command you are running

Metadata

Metadata

Assignees

No one assigned

    Labels

    stage/needs-triageAutomatically applied to new issues and PRs, indicating they haven't been looked at.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions