fix: resubmit project with same name no longer corrupts skill linkage#587
Open
abduznik wants to merge 1 commit into
Open
Conversation
When resubmitting a major project with the same name as a previous submission, the re-query filtered by (name, uid) returned the OLDEST matching project instead of the one just created. This caused: 1. Skills to be linked to the wrong (old) project 2. A PRIMARY KEY collision on major_project_skills when the same skills already existed for that old project 3. The new project to be left orphaned with zero skills Fix: query by project.id (the known primary key) instead of by (name, uid). After db.session.commit(), SQLAlchemy has populated project.id with the auto-generated PK, so we can identify the correct project unambiguously. Test: isolated testbench using SQLAlchemy with the exact production model definitions confirms: - Bug: re-query by (name, uid) returns id=1 when id=2 is expected - Fix: re-query by project.id returns the correct project every time - Each resubmission correctly links skills to its own project
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.
Problem
Resubmitting a major project with the same name as a previous submission fails with an integrity error. The skills get linked to the wrong project.
Root Cause
The re-query at
conditional/blueprints/major_project_submission.py:125-128filters by(name, uid), which returns any matching project — not necessarily the one just created. When skills are then inserted using the wrong project ID, the composite PK(project_id, skill)collides with already-existing skills.Fix
Query by the known primary key (
project.id) instead of(name, uid). Afterdb.session.commit(), SQLAlchemy has populatedproject.idwith the auto-generated value.Test
Created an isolated testbench using SQLAlchemy with the exact production model definitions:
Fixes #586