Skip to content

Fix IntegrityError on rerun of collect_and_create_codebase_resources - #2225

Open
reehassan wants to merge 1 commit into
aboutcode-org:mainfrom
reehassan:fix/1712-codebase-resource-duplicate-run
Open

Fix IntegrityError on rerun of collect_and_create_codebase_resources#2225
reehassan wants to merge 1 commit into
aboutcode-org:mainfrom
reehassan:fix/1712-codebase-resource-duplicate-run

Conversation

@reehassan

Copy link
Copy Markdown

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.

Screenshot 2026-09-04 at 14-34-47 ScanCode io rerun-bug-repro

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).

Screenshot 2026-09-04 at 16-43-07 ScanCode io rerun-bug-repro

Checklist

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>
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.

Weird message when trying to rerun map_deploy_to_devel pipeline

1 participant