Skip to content

fix: [tests] Comment on an existing vulnerability, not a hardcoded CVE#97

Merged
cedricbonhomme merged 1 commit into
mainfrom
fix-comment-vulnerability-existence
Jul 22, 2026
Merged

fix: [tests] Comment on an existing vulnerability, not a hardcoded CVE#97
cedricbonhomme merged 1 commit into
mainfrom
fix-comment-vulnerability-existence

Conversation

@cedricbonhomme

Copy link
Copy Markdown
Member

Summary

Follow-up to #96. Vulnerability-Lookup now rejects comment creation when the commented-on vulnerability is not present in storage — added in vulnerability-lookup#497 (comment.py:385, returns 404 "Vulnerability not found."). The two local comment tests hardcoded CVE-2024-20401, which the CI sample instance never imports (it loads pysec advisories), so create_comment returned an error dict and the tests failed with KeyError: 'data'.

Change

test_comments_local and test_create_user_comment now fetch a vulnerability the instance actually has — get_last(source="pysec", number=1) (the same call test_get_last already relies on) — and comment on its id instead of a hardcoded CVE. If no vulnerability is available the test skips (return None), consistent with the existing guards in this file.

Left untouched: test_get_comments_public (runs only against the public instance, where the seeded comments exist) and the sightings/EPSS tests (sighting creation has no existence check and never failed). Only the primary vulnerability field is existence-checked, so the related_vulnerabilities literals stay as-is.

Notes

This is a test-side adaptation to the intended new API behaviour (comments must attach to a known vulnerability), not a change to the client library, which continues to work unchanged.

🤖 Generated with Claude Code

Vulnerability-Lookup now rejects comment creation when the target
vulnerability is absent from storage (added in vulnerability-lookup#497).
The two local comment tests hardcoded CVE-2024-20401, which the CI
sample instance never imports, so create_comment returned 404
'Vulnerability not found'.

Fetch a vulnerability actually present in the instance via
get_last(source='pysec', number=1) and comment on it (the CI instance
loads pysec). The test skips if no vulnerability is available.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cedricbonhomme
cedricbonhomme merged commit 9c1c39c into main Jul 22, 2026
10 checks passed
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.

1 participant