Skip to content

fix: remove return from finally block to resolve Python 3.14 SyntaxWa… - #767

Merged
jcstorms1 merged 3 commits into
mainfrom
storms/community-pr-759
Apr 2, 2026
Merged

fix: remove return from finally block to resolve Python 3.14 SyntaxWa…#767
jcstorms1 merged 3 commits into
mainfrom
storms/community-pr-759

Conversation

@jcstorms1

Copy link
Copy Markdown
Contributor

What does this PR do?

This is a community PR #759

Removes return self.blocking_response from the finally block in _LambdaDecorator.call and defers it to after the try/except/finally block, eliminating the SyntaxWarning: 'return' in a 'finally' block emitted by Python 3.14 at cold start.

Motivation

Python 3.14 introduced a SyntaxWarning for return/break/continue inside finally blocks because a return in finally silently suppresses any exception actively propagating through the try/except. This warning was firing on every Lambda cold start and polluting CloudWatch logs for anyone running on the Python 3.14 runtime.

Testing Guidelines

Additional Notes

Types of Changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog
  • This PR passes the integration tests (ask a Datadog member to run the tests)

…rning
Python 3.14 raises a SyntaxWarning for inside a block.
Move the blocking_response return to after the try/except/finally in
_LambdaDecorator.__call__, preserving all AppSec blocking execution paths.
Add a regression test confirming handler exceptions still propagate when
AppSec is enabled and no blocking response is active.
Signed-off-by: Jordan <jordan.storms@datadoghq.com>
Signed-off-by: Jordan <jordan.storms@datadoghq.com>
Signed-off-by: Jordan <jordan.storms@datadoghq.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@jcstorms1@purple4reina