Patch 1#1045
Closed
eric-teambridge wants to merge 3 commits intoDataDog:masterfrom
Closed
Conversation
extract_ddtags_from_message checks for a service tag override using `if "service:" in` which returns true if there's a tag key that ends with `service`, eg `mail_send_service:production`.
This causes the lambda to enter the conditional to extract the tag to a first class datadog tag, but the enclosed logic includes a non-defaulted generator which checks for `startswith("service:")`. Since this second check does _not_ match the example, the generator has no elements, and the call to `next` causes the lambda to crash.
This change swaps the check to use the same split/startswith functionality that's used inside the conditional.
ViBiOh
approved these changes
Jan 15, 2026
Contributor
|
Thank you for spotting that and fixing it. There is a small code format issue on your pull-request (see failed Linter job). Once you'll fix it, I can merge and ask for a patch release. |
Contributor
Author
|
@ViBiOh Patched it, ran the linter locally, should be good now. |
Contributor
|
I created a rebased PR #1050 to solve the linter issues |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This change swaps the check to use the same split/startswith functionality that's used inside the conditional.
Motivation
extract_ddtags_from_message checks for a service tag override using
if "service:" inwhich returns true if there's a tag key that ends withservice, egmail_send_service:production.This causes the lambda to enter the conditional to extract the tag to a first class datadog tag, but the enclosed logic includes a non-defaulted generator which checks for
startswith("service:"). Since this second check does not match the example, the generator has no elements, and the call tonextcauses the lambda to crash.Testing Guidelines
Added a unit test that fails on main in the same way we experienced in prod. The test passes with this change.
Additional Notes
Logs from the lambda when this crash occurred in our prod environment:
[ERROR] StopIteration
Traceback (most recent call last):
File "/opt/python/datadog_lambda/wrapper.py", line 239, in call
"""Executes when the wrapped function gets called"""
File "/opt/python/ddtrace/contrib/internal/aws_lambda/patch.py", line 119, in call
self.response = self.func(*args, **kwargs)
File "/opt/python/datadog_lambda/wrapper.py", line 242, in call
self.response = self.func(event, context, **kwargs)
File "/opt/python/lambda_function.py", line 85, in datadog_forwarder
enriched = enrich(parsed, cache_layer)
File "/opt/python/steps/enrichment.py", line 30, in enrich
extract_ddtags_from_message(event)
File "/opt/python/steps/enrichment.py", line 171, in extract_ddtags_from_message
event[DD_SERVICE] = next(
NB: The log was cut off like that in cloudwatch.
Types of changes
Check all that apply