Skip to content

fix: prevent TypeError in pathlib when searching for explicit files#719

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/pathlib-typeerror
Open

fix: prevent TypeError in pathlib when searching for explicit files#719
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/pathlib-typeerror

Conversation

@sentry

@sentry sentry Bot commented Jun 12, 2026

Copy link
Copy Markdown

This PR addresses a TypeError: '_PosixFlavour' object is not reversible that occurred during the upload-coverage command, specifically when --disable-search was used in conjunction with explicitly listed --file paths.

Root Cause:
The issue stemmed from an incompatibility between the PyInstaller-frozen CLI binary's bundled pathlib internals (likely from a newer Python version) and the CPython 3.9.5 runtime environment. The pathlib._PosixFlavour.parse_parts method, called during path construction, would fail when reversed() was invoked on an incompatible _PosixFlavour object.

This crash was triggered because, even with --disable-search and explicit --file arguments, the get_user_specified_files function in file_finder.py was still performing a full os.walk over the repository via search_files. This os.walk would iterate through potentially thousands of files, leading to repeated pathlib.Path constructions and eventually hitting the problematic internal pathlib API.

Solution:
The search_files call within get_user_specified_files was redundant when explicit files are provided, as the CLI already knows which files to look for. The solution removes this unnecessary os.walk-based search. Instead, for each explicitly listed file, the function now directly checks for its existence using filepath.exists() (for absolute paths or paths relative to the current working directory) and (self.search_root / filepath).exists() (for paths relative to the search root).

This change bypasses the problematic os.walk and the pathlib internal API call that caused the TypeError, resolving the crash while maintaining the intended functionality of locating user-specified files.

Fixes CLI-EZ

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
700 1 699 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 214 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

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