Skip to content

fix: prevent repeated template sequence names#482

Open
manulera wants to merge 1 commit into
masterfrom
prevent-repeated-template-names
Open

fix: prevent repeated template sequence names#482
manulera wants to merge 1 commit into
masterfrom
prevent-repeated-template-names

Conversation

@manulera
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to prevent duplicate template sequence names within the same workspace (including case-insensitive duplicates), aligning API behavior with a stronger workspace-scoped uniqueness rule.

Changes:

  • Add a workspace-scoped, case-insensitive uniqueness enforcement for template sequence names (API-side checks + DB constraint).
  • Update sequence patching to enforce the same constraint when renaming template sequences.
  • Add tests covering duplicate-name creation/rename scenarios and cross-workspace allowance.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
uv.lock Bumps editable package versions to 1.6.1.
packages/opencloning-db/tests/test_template_sequences.py Adds coverage for 409 conflicts on duplicate template sequence names (incl. case-insensitive) and validates cross-workspace behavior.
packages/opencloning-db/src/opencloning_db/routers/template_sequences.py Enforces name availability pre-check and converts uniqueness-related IntegrityError into a 409 response.
packages/opencloning-db/src/opencloning_db/routers/sequences.py Enforces template-sequence name availability on rename and handles uniqueness IntegrityError as 409 for template sequences.
packages/opencloning-db/src/opencloning_db/models.py Adds a partial unique index for template sequence names (case-insensitive) and introduces helper functions to check/raise on conflicts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +208 to +216
__table_args__ = (
Index(
'uq_input_entity_template_sequence_workspace_name',
'workspace_id',
text('lower(name)'),
unique=True,
postgresql_where=text("type = 'template_sequence'"),
),
)
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.12%. Comparing base (bd763b4) to head (87179ce).

Files with missing lines Patch % Lines
...cloning-db/src/opencloning_db/routers/sequences.py 44.44% 5 Missing ⚠️
...b/src/opencloning_db/routers/template_sequences.py 70.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #482      +/-   ##
==========================================
- Coverage   98.29%   98.12%   -0.18%     
==========================================
  Files          59       59              
  Lines        4235     4258      +23     
==========================================
+ Hits         4163     4178      +15     
- Misses         72       80       +8     
Flag Coverage Δ
unittests 98.12% <71.42%> (-0.18%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants