Skip to content

fix: narrow bare except Exception in version fallback (import of github/spec-kit#3835) - #124

Open
one-kash wants to merge 1 commit into
mainfrom
import/pr-3835
Open

fix: narrow bare except Exception in version fallback (import of github/spec-kit#3835)#124
one-kash wants to merge 1 commit into
mainfrom
import/pr-3835

Conversation

@one-kash

Copy link
Copy Markdown

Imported from upstream PR github#3835
Original author: @Quratulain-bilal
Original head branch: fix/assets-narrow-exception


Summary

Replace overly broad except Exception with specific exception types in get_speckit_version() fallback.

Changes

  • _assets.py: Narrow outer exception to PackageNotFoundError
  • _assets.py: Narrow inner exception to (OSError, KeyError, ValueError)

Replace overly broad except Exception with specific exception types:
- importlib.metadata.PackageNotFoundError for missing package
- (OSError, KeyError, ValueError) for pyproject.toml read/parse errors

This prevents silently swallowing unexpected errors like AttributeError
or RecursionError from broken tomllib or malformed pyproject.toml.
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.

2 participants