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 error logging during AWS init #3943

Merged
merged 2 commits into from
Feb 20, 2025

Conversation

itsbjoern
Copy link
Contributor

Hi I noticed that the AWS integration fails to capture errors during the init phase (at least in python 3.8 and above environments).

It appears tests for this were disabled after a change in AWS' own runtime environment: #3592

I was able to hunt down a change from a few months ago where it seems like string serialisation of the json payload was disabled and instead the post_init_error is invoked directly with the json payload

aws/aws-lambda-python-runtime-interface-client@a37a43a#diff-4513a869520b19ae4e30058106d7c3b5ddbb79216b5e9bd922d83389fb86c603R483

This breaks and causes an error internally when trying to parse the string back into json, and the error is actually swallowed because of with capture_internal_exceptions():.

I did a bit of trialling in the test suite and it seems like python3.8 still is invoked with a string, whereas 3.9+ is invoked with JSON. But because I'm not 100% sure on the behaviour I just opted to check the arg type instead. I couldn't find any better documentation on this behaviour than the link above which just seems to be a continuous stream of updates to the main AWS python image.

@itsbjoern
Copy link
Contributor Author

Hey @antonpirker, really sorry to ping you like this but just wondering if there is any other action required from me here. Happy to patch this in our own codebase for now, but I'd love to help out where I can to see this fixed upstream.

@antonpirker antonpirker added the Trigger: tests using secrets PR code is safe; run CI label Feb 20, 2025
Copy link

codecov bot commented Feb 20, 2025

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 79.54%. Comparing base (4d64c4e) to head (3b3125e).
Report is 1 commits behind head on master.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
sentry_sdk/integrations/aws_lambda.py 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3943      +/-   ##
==========================================
- Coverage   79.55%   79.54%   -0.01%     
==========================================
  Files         140      140              
  Lines       15512    15515       +3     
  Branches     2628     2629       +1     
==========================================
+ Hits        12341    12342       +1     
- Misses       2335     2338       +3     
+ Partials      836      835       -1     
Files with missing lines Coverage Δ
sentry_sdk/integrations/aws_lambda.py 30.91% <0.00%> (-0.46%) ⬇️

... and 1 file with indirect coverage changes

Copy link
Member

@antonpirker antonpirker left a comment

Choose a reason for hiding this comment

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

Very cool @itsbjoern, thanks for your work!

As this is still guarded by our capture_internal_exceptions and the re-enabled test case is also happy, I think it is safe to merge this!

@antonpirker antonpirker merged commit 2423299 into getsentry:master Feb 20, 2025
142 of 145 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Trigger: tests using secrets PR code is safe; run CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants