Skip to content

fix: guard against raising None when Bedrock retries are exhausted#15

Merged
opensource-SantanderAI merged 1 commit into
mainfrom
fix/bedrock-raise-guard
Jul 8, 2026
Merged

fix: guard against raising None when Bedrock retries are exhausted#15
opensource-SantanderAI merged 1 commit into
mainfrom
fix/bedrock-raise-guard

Conversation

@opensource-SantanderAI

Copy link
Copy Markdown
Contributor

What

In the retry loop's for/else branch, last_exc can still be None when max_retries=0, so raise last_exc would surface as a bare TypeError. This adds an explicit guard raising a descriptive RuntimeError, and removes the type: ignore[misc] that was masking the type-narrowing gap.

Why

Resolves CodeQL py/illegal-raise (alert #23). No behavior change on any path where a retryable exception was captured.

If _max_retries is 0 the retry loop never runs and last_exc stays None,
so the for-else branch would execute 'raise None' and surface as a bare
TypeError. Raise a descriptive RuntimeError instead and drop the
'type: ignore' that was masking the narrowing gap.

Resolves CodeQL py/illegal-raise (alert #23).
@opensource-SantanderAI
opensource-SantanderAI requested review from a team as code owners July 8, 2026 10:50
@opensource-SantanderAI
opensource-SantanderAI merged commit dd4ba6e into main Jul 8, 2026
11 checks passed
@opensource-SantanderAI
opensource-SantanderAI deleted the fix/bedrock-raise-guard branch July 8, 2026 11:06
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant