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 exception handling for events with requestContext #2418

Merged
merged 4 commits into from
Apr 25, 2024

Conversation

alessandrobologna
Copy link
Contributor

@alessandrobologna alessandrobologna commented Apr 14, 2024

Description

For Lambda invocations with an event that contains a requestContext property, the current code throws an UnboundLocalError if an exception (of other type) is thrown in the function execution, due to the result variable being accessed before being initialized. This PR simply makes sure that is initialized before being used.

Fixes #2399

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • ran tox -e py38-test-instrumentation-aws-lambda
  • ran tox -e py39-test-instrumentation-aws-lambda
  • ran tox -e py310-test-instrumentation-aws-lambda
  • ran tox -e py311-test-instrumentation-aws-lambda

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

Copy link

linux-foundation-easycla bot commented Apr 14, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link
Contributor

@xrmx xrmx left a comment

Choose a reason for hiding this comment

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

Thanks, nice catch!

@lzchen
Copy link
Contributor

lzchen commented Apr 23, 2024

@alessandrobologna

Please add a CHANGELOG entry.

@alessandrobologna alessandrobologna requested a review from a team April 23, 2024 16:38
@alessandrobologna
Copy link
Contributor Author

Added CHANGELOG entry.

Copy link
Contributor

@xrmx xrmx left a comment

Choose a reason for hiding this comment

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

@alessandrobologna you added more changelog entries than this PR 😅

@alessandrobologna
Copy link
Contributor Author

@xrmx apologies, this should be fixed now

Copy link
Contributor

@xrmx xrmx left a comment

Choose a reason for hiding this comment

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

Thanks!

@ocelotl ocelotl merged commit d5b5925 into open-telemetry:main Apr 25, 2024
258 checks passed
@jamesrwhite
Copy link

👋 Hey, we've just run into this issue. Is it possible a new release can be made soon that includes this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS Lambda/APIGW unhandled exception causes UnboundLocalError
5 participants