Skip to content

fix(scan): skip invalid package specifiers instead of crashing#880

Open
raywcm wants to merge 1 commit into
pyupio:mainfrom
raywcm:fix/invalid-specifier-tensorflow
Open

fix(scan): skip invalid package specifiers instead of crashing#880
raywcm wants to merge 1 commit into
pyupio:mainfrom
raywcm:fix/invalid-specifier-tensorflow

Conversation

@raywcm

@raywcm raywcm commented Jun 4, 2026

Copy link
Copy Markdown

Summary

Running safety scan against an environment with tensorflow causes an unhandled crash:

Unhandled exception happened: Invalid specifier: '=2.7.0'

The tensorflow vulnerability database entry contains the invalid specifier string "=2.7.0" (single equals sign), which is not a valid PEP 440 specifier. The SpecifierSet() parser from packaging.specifiers raises InvalidSpecifier, and the exception propagates unhandled.

Reproduction

Install tensorflow and run safety scan:

$ pip install tensorflow
$ safety scan

Expected: the scan completes, reporting known vulnerabilities.
Actual: Unhandled exception happened: Invalid specifier: '=2.7.0'

Fix

Wrap the SpecifierSet() call in safety/scan/ecosystems/python/main.py in a try/except to catch InvalidSpecifier, skip the invalid entry, and log a warning. This allows the scan to continue processing the remaining valid specifiers.

Fixes #873

…o#873)

Invalid specifier strings (e.g. '=2.7.0' in the tensorflow
vulnerability database entry) cause a crash with an unhandled
InvalidSpecifier exception from packaging.specifiers.

This fix wraps the SpecifierSet() parsing in a try/except to
gracefully skip invalid specifiers with a warning log message,
allowing the scan to continue normally.
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a9c72dfe-723a-4a57-83ce-f0603eb4ed2d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

tensorflow vuln-db entry contains invalid specifier "=2.7.0"

1 participant