Skip to content

fix: Handle KeyError in CodecovOption fallback lookups - #788

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/fallback-keyerror-handling
Open

sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/fallback-keyerror-handling

Conversation

@sentry

@sentry sentry Bot commented Sep 12, 2026

Copy link
Copy Markdown

This PR addresses an AssertionError in CLI validation tests (e.g., validate_empty_upload.py) caused by a KeyError when CodecovOption.get_default attempts to retrieve fallback values from CI adapter mocks.

The root cause was that mock CI adapters, which often use direct dictionary access ([field]), did not always contain all FallbackFieldEnum keys that the CLI command might query. When a missing key was accessed, it raised a KeyError, which was then captured by the CLI runner, leading to a non-zero exit code and failing assertions.

The fix involves wrapping the ci_adapter.get_fallback_value and versioning_system.get_fallback_value calls within CodecovOption.get_default in try/except KeyError blocks. If a KeyError occurs, res is set to None, allowing the fallback mechanism to gracefully continue as if no value was found for that field, rather than crashing.

Fixes CLI-H4

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
723 1 722 1
View the full list of 1 ❄️ flaky test(s)
api.temp.calculator.test_calculator::test_divide

Flake rate in main: 100.00% (Passed 0 times, Failed 1726 times)

Stack Traces | 0.001s run time
def
                test_divide():
                > assert Calculator.divide(1, 2) == 0.5
                E assert 1.0 == 0.5
                E + where 1.0 = <function Calculator.divide at 0x104c9eb90>(1, 2)
                E + where <function Calculator.divide at 0x104c9eb90> = Calculator.divide
                .../temp/calculator/test_calculator.py:30: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@sentry

sentry Bot commented Sep 12, 2026

Copy link
Copy Markdown
Author

⚠️ Seer needs additional GitHub permissions

Seer wants to keep iterating on this pull request to get CI passing, but the Sentry GitHub App installation is missing permissions it needs to read the failing checks and push a fix.

Review and accept the updated permissions to let Seer continue: https://github.com/organizations/codecov/settings/installations/86101127/permissions/update

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.

0 participants