Skip to content

fix: resubmit project with same name no longer corrupts skill linkage#587

Open
abduznik wants to merge 1 commit into
ComputerScienceHouse:developfrom
abduznik:fix/major-project-resubmit-skill-collision
Open

fix: resubmit project with same name no longer corrupts skill linkage#587
abduznik wants to merge 1 commit into
ComputerScienceHouse:developfrom
abduznik:fix/major-project-resubmit-skill-collision

Conversation

@abduznik

@abduznik abduznik commented Jun 29, 2026

Copy link
Copy Markdown

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-128 filters 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). After db.session.commit(), SQLAlchemy has populated project.id with the auto-generated value.

Test

Created an isolated testbench using SQLAlchemy with the exact production model definitions:

Scenario Result
Initial submission ✅ Skills linked correctly
Resubmit same name+skills (buggy) ❌ Re-query returns old project ID, PK collision
Resubmit same name+skills (fixed) ✅ Each project gets its own skills
3 submissions, all same name+skills ✅ All 3 projects have all 3 skills

Fixes #586

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
@abduznik abduznik marked this pull request as ready for review June 29, 2026 04:07
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.

Major projects cannot be submitted with the same name and repeated skills

1 participant