Skip to content

Commit 74313f3

Browse files
committed
fix: narrow exception catch in extension manifest parsing
Replace broad 'except Exception: pass' with specific exception types (ExtValidationError, yaml.YAMLError) and add explanatory comment for the intentional fallback to convention-based lookup.
1 parent aaec670 commit 74313f3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/specify_cli/presets.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,7 +2327,7 @@ def _find_in_subdirs(base_dir: Path) -> Optional[Path]:
23272327
ext_manifest_path = ext_dir / "extension.yml"
23282328
if ext_manifest_path.exists():
23292329
try:
2330-
from .extensions import ExtensionManifest
2330+
from .extensions import ExtensionManifest, ValidationError as ExtValidationError
23312331
ext_manifest = ExtensionManifest(ext_manifest_path)
23322332
for cmd in ext_manifest.commands:
23332333
if cmd.get("name") == template_name:
@@ -2337,7 +2337,9 @@ def _find_in_subdirs(base_dir: Path) -> Optional[Path]:
23372337
if c.exists():
23382338
candidate = c
23392339
break
2340-
except Exception:
2340+
except (ExtValidationError, yaml.YAMLError):
2341+
# Invalid extension manifest — fall back to
2342+
# convention-based lookup (already attempted above).
23412343
pass
23422344
if candidate:
23432345
if ext_meta:

0 commit comments

Comments
 (0)