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

fix: add typecheck to lambda wrapper #533

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion datadog_lambda/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,10 @@ def is_legacy_lambda_step_function(event):
"""
Check if the event is a step function that called a legacy lambda
"""
event = event.get("Payload", {})
if not isinstance(event, dict) or "Payload" not in event:
return False

event = event.get("Payload")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Code Quality Violation

variable name is the same as a function parameter (...read more)

A function parameter should only be read and not be modified. If your intent is to modify the value of the parameter, return the value in the function and handle the new value in the caller of the function.

View in Datadog  Leave us feedback  Documentation

return "Execution" in event and "StateMachine" in event and "State" in event


Expand Down
3 changes: 3 additions & 0 deletions tests/test_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,9 @@ def test_is_legacy_lambda_step_function(self):
}
self.assertFalse(is_legacy_lambda_step_function(sf_event))

other_event = ["foo", "bar"]
self.assertFalse(is_legacy_lambda_step_function(other_event))


class TestXRayContextConversion(unittest.TestCase):
def test_convert_xray_trace_id(self):
Expand Down
Loading