Skip to content

When the response of lambda contain data of type Decimal, datadog raise except TypeError: 'decimal.Decimal' object is not iterable #213

@jairoandrescastaneda

Description

@jairoandrescastaneda

Expected Behavior

When return response from DynamoDB and DynamoDB contains data of type Decimal

Actual Behavior

Get data of DynamoDB that contains data of type Decimal and raise next exception except TypeError: 'decimal.Decimal' object is not iterable And the trace and log data is not sent complete.

Steps to Reproduce the Problem

  1. Get data from Dynamodb inside handler and return response.

In the code core de datadog_lambda in the line 37 raises of exception because Decimal is instance of object, but this is not iterable

  if isinstance(obj, object):
      for k in obj:
          v = obj.get(k)
          formatted_key = "{}.{}".format(key, k)
          tag_object(span, formatted_key, v, depth)
      return

Specifications

  • Datadog Lambda Layer version:

Screenshot (99)

  • Python version: 3.8

Stacktrace

File "/opt/python/lib/python3.8/site-packages/datadog_lambda/wrapper.py", line 203, in _after
tag_object(self.span, "function.response", self.response)
File "/opt/python/lib/python3.8/site-packages/datadog_lambda/tag_object.py", line 40, in tag_object
tag_object(span, formatted_key, v, depth)
File "/opt/python/lib/python3.8/site-packages/datadog_lambda/tag_object.py", line 40, in tag_object
tag_object(span, formatted_key, v, depth)
File "/opt/python/lib/python3.8/site-packages/datadog_lambda/tag_object.py", line 40, in tag_object
tag_object(span, formatted_key, v, depth)
[Previous line repeated 4 more times]
File "/opt/python/lib/python3.8/site-packages/datadog_lambda/tag_object.py", line 37, in tag_object
for k in obj:
TypeError: 'decimal.Decimal' object is not iterable

Metadata

Metadata

Assignees

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