-
Notifications
You must be signed in to change notification settings - Fork 36
Fix: Narrow INSTALL_ERROR_TYPES catch scope #516
Copy link
Copy link
Open
Labels
Description
INSTALL_ERROR_TYPES in exceptions.py catches broadly:
INSTALL_ERROR_TYPES = (FileExistsError, AgrError, OSError, ValueError)Catching OSError and ValueError broadly risks swallowing unexpected errors and weakens the value of the exception hierarchy.
Proposal
- Replace bare
ValueErrorraises within install/sync paths with specificAgrErrorsubclasses (e.g.,InvalidHandleError,ConfigError) - Narrow
OSErrorto specific subclasses (PermissionError,FileNotFoundError) where the failure mode is known - Audit all raise sites that currently raise
ValueErrorwithin the install/sync code paths and convert to the appropriateAgrErrorsubclass
Goal state
INSTALL_ERROR_TYPES = (FileExistsError, AgrError, PermissionError, FileNotFoundError)Or ideally just (AgrError, FileExistsError) if all ValueError and OSError sites are converted.
Affected files
agr/exceptions.py—INSTALL_ERROR_TYPESdefinitionagr/fetcher.py— primary consumer of the catch tupleagr/commands/sync.py— usesINSTALL_ERROR_TYPESin except clausesagr/commands/add.py— usesINSTALL_ERROR_TYPESin except clauses- Various modules that raise
ValueErrorin install paths
Context
Identified in architecture audit: docs/contributing/architecture-audit.md
Reactions are currently unavailable