Skip to content

Fix incorrect exception handling in insert_advisory_v2 (#2081) - #2083

Closed
Adityakk9031 wants to merge 1 commit into
aboutcode-org:mainfrom
Adityakk9031:#2081
Closed

Fix incorrect exception handling in insert_advisory_v2 (#2081)#2083
Adityakk9031 wants to merge 1 commit into
aboutcode-org:mainfrom
Adityakk9031:#2081

Conversation

@Adityakk9031

@Adityakk9031 Adityakk9031 commented Dec 25, 2025

Copy link
Copy Markdown
Contributor

Problem

insert_advisory_v2 uses AdvisoryV2.objects.get_or_create(...), but the except block incorrectly catches Advisory.MultipleObjectsReturned.
When duplicate AdvisoryV2 records exist, Django raises AdvisoryV2.MultipleObjectsReturned, which was not being caught, causing the exception to propagate and break the pipeline.

Solution

Updated the exception handling to catch the correct exception:

Replaced Advisory.MultipleObjectsReturned

With AdvisoryV2.MultipleObjectsReturned

This ensures duplicate AdvisoryV2 records are handled correctly and prevents unexpected crashes during advisory ingestion.

Related Issue

Fixes: Incorrect try except in insert_advisory_v2 #2081
#2081

@Adityakk9031
Adityakk9031 deleted the #2081 branch December 25, 2025 18:03
@Adityakk9031
Adityakk9031 restored the #2081 branch December 25, 2025 18:04
@Adityakk9031
Adityakk9031 deleted the #2081 branch December 25, 2025 18:04
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