Fix IntegrityError on rerun of collect_and_create_codebase_resources - #2225
Open
reehassan wants to merge 1 commit into
Open
Fix IntegrityError on rerun of collect_and_create_codebase_resources#2225reehassan wants to merge 1 commit into
reehassan wants to merge 1 commit into
Conversation
Rerunning a pipeline that calls collect_and_create_codebase_resources() on a project that already has resources raises a raw IntegrityError. Catch it and re-raise with a message pointing to the Reset feature. Fixes aboutcode-org#1712 Signed-off-by: reehassan <theailaboratories@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rerunning a pipeline that calls collect_and_create_codebase_resources() on a project that already has resources raises a raw IntegrityError. Catch it and re-raise with a message pointing to the Reset feature.
Fixes #1712
Issues
Changes
Rerunning map_deploy_to_develop on a project that already has resources blows up on the (project, path) unique constraint for CodebaseResource. Second run tries to insert to/from again, Postgres rejects it, raw IntegrityError hits the UI.
Root cause is in scanpipe/pipes/init.py, collect_and_create_codebase_resources(). Since rerun without reset isn't really supported anyway, wrapped the bulk_create there in try/except and re-raise with a message pointing at Reset instead of the bare trace.
Added a test in scanpipe/tests/pipes/test_pipes.py, right next to the existing test_scanpipe_pipes_collect_and_create_codebase_resources, that reruns the function and checks for the new message.
Ran the full suite locally, passes except one qcow2 extraction test that's already broken on main too (confirmed via git stash).
Checklist