Skip to content

NoneType object has no attribute 'items' #249

Closed
@ddhanak

Description

@ddhanak

Expected Behavior

Triggering a lambda through an API Gateway without providing headers should not throw an error.

Actual Behavior

There is an error thrown when trying to extract the headers from the context.

Steps to Reproduce the Problem

  1. Send a request using a lambda backed API Gateway endpoint (done through console) without providing headers
  2. Check cloudwatch logs

Specifications

  • Datadog Lambda Layer version: 62
  • Python version: 3.9

Stacktrace

2022-09-12T10:37:18.731-04:00	Traceback (most recent call last):
  2022-09-12T10:37:18.731-04:00	File "/opt/python/lib/python3.9/site-packages/datadog_lambda/wrapper.py", line 167, in _before
  2022-09-12T10:37:18.731-04:00	dd_context, trace_context_source = extract_dd_trace_context(
  2022-09-12T10:37:18.731-04:00
File "/opt/python/lib/python3.9/site-packages/datadog_lambda/tracing.py", line 342, in extract_dd_trace_context
  File "/opt/python/lib/python3.9/site-packages/datadog_lambda/tracing.py", line 342, in extract_dd_trace_context
  2022-09-12T10:37:18.731-04:00	) = extract_context_from_http_event_or_context(event, lambda_context)
  2022-09-12T10:37:18.731-04:00
File "/opt/python/lib/python3.9/site-packages/datadog_lambda/tracing.py", line 178, in extract_context_from_http_event_or_context
  File "/opt/python/lib/python3.9/site-packages/datadog_lambda/tracing.py", line 178, in extract_context_from_http_event_or_context
  2022-09-12T10:37:18.731-04:00	lowercase_headers = {k.lower(): v for k, v in headers.items()}
  2022-09-12T10:37:18.731-04:00	AttributeError: 'NoneType' object has no attribute 'items'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions