fix: remove return statements from finally blocks#10102
Merged
jfagoagas merged 4 commits intoprowler-cloud:masterfrom Mar 27, 2026
Merged
fix: remove return statements from finally blocks#10102jfagoagas merged 4 commits intoprowler-cloud:masterfrom
jfagoagas merged 4 commits intoprowler-cloud:masterfrom
Conversation
…ng exceptions A return statement in a finally block silently suppresses any in-flight exception, including BaseException types like KeyboardInterrupt. This makes debugging difficult and can mask real errors. Move return variable initialization before the try block and replace finally: return with a plain return after the try/except. This preserves the existing behavior (returning default values on error) while allowing unexpected exceptions to propagate correctly. Fixes prowler-cloud#5520
Contributor
|
✅ Conflict Markers Resolved All conflict markers have been successfully resolved in this pull request. |
7 tasks
…move-return-in-finally-blocks
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #10102 +/- ##
==========================================
+ Coverage 26.36% 36.13% +9.76%
==========================================
Files 839 1072 +233
Lines 23898 33936 +10038
==========================================
+ Hits 6301 12262 +5961
- Misses 17597 21674 +4077
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
danibarranqueroo
approved these changes
Mar 27, 2026
Member
|
Thanks for this @apoorvdarshan 👏 |
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.
Summary
returnstatements fromfinallyblocks across 5 files to prevent silent exception swallowingtryblocks and replacedfinally: returnwith plainreturnafter try/exceptFiles Changed
prowler/providers/aws/services/iam/iam_service.pyprowler/providers/aws/services/organizations/organizations_service.pyprowler/lib/check/custom_checks_metadata.pyprowler/providers/aws/services/iam/iam_user_two_active_access_key/iam_user_two_active_access_key.pyprowler/providers/gcp/gcp_provider.pyContext
A
returnin afinallyblock silently suppresses any in-flight exception, includingBaseExceptiontypes likeKeyboardInterrupt. See Python docs.Fixes #5520
Test plan