Skip to content

Quality: Fragile version parsing can crash with unclear error#4752

Closed
tuanaiseo wants to merge 1 commit intoboto:developfrom
tuanaiseo:contribai/improve/quality/fragile-version-parsing-can-crash-with-u
Closed

Quality: Fragile version parsing can crash with unclear error#4752
tuanaiseo wants to merge 1 commit intoboto:developfrom
tuanaiseo:contribai/improve/quality/fragile-version-parsing-can-crash-with-u

Conversation

@tuanaiseo
Copy link
Copy Markdown

Problem

get_version() assumes the regex always matches and calls .group(1) directly. If __version__ format changes or file contents differ, setup fails with an unhelpful AttributeError.

Severity: medium
File: setup.py

Solution

Validate regex match before dereferencing and raise a clear exception (e.g., RuntimeError('Unable to find __version__ in boto3/__init__.py')).

Changes

  • setup.py (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

`get_version()` assumes the regex always matches and calls `.group(1)` directly. If `__version__` format changes or file contents differ, setup fails with an unhelpful `AttributeError`.

Affected files: setup.py

Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
@SamRemis
Copy link
Copy Markdown
Contributor

SamRemis commented Apr 9, 2026

Hi @tuanaiseo,

What scenarios are you running into this error? All versions should follow this regex. Can you provide more information on your use case or how you're encountering this?

@SamRemis SamRemis closed this Apr 22, 2026
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