Skip to content

Fix: create_new_library existence check uses pre-safe-name string (#1155)#1305

Open
shr8769 wants to merge 1 commit into
llmware-ai:mainfrom
shr8769:fix-1155-library-safe-name
Open

Fix: create_new_library existence check uses pre-safe-name string (#1155)#1305
shr8769 wants to merge 1 commit into
llmware-ai:mainfrom
shr8769:fix-1155-library-safe-name

Conversation

@shr8769

@shr8769 shr8769 commented Jun 17, 2026

Copy link
Copy Markdown

Fixes #1155.

create_new_library() ran the database-level safe_name() conversion
(which rewrites characters like '-' to '_' on sqlite/postgres) after
check_if_library_exists(). Calling create_new_library with the same
original name a second time checked existence under the un-rewritten
name, found nothing, and attempted to recreate the library — colliding
with the already-registered remapped name and raising an
IntegrityError.

This moves the safe_name conversion before the existence check, so
both operate on the same final name. Added a regression test
(test_create_new_library_idempotent_with_unsafe_name) that reproduces
the original failure on sqlite and confirms the fix.

Verified locally:

  • Before the fix: second create_new_library() call with the same
    unsafe name raised sqlite3.IntegrityError.
  • After the fix: both calls succeed and resolve to the same library.
  • New regression test passes: 1 passed.

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.

Library.create_new_library checks existence wrong

1 participant