@@ -372,6 +372,32 @@ def test_chroma_backend_create_collection_sets_hnsw_bloat_guard(tmp_path):
372372 assert col .metadata .get ("hnsw:sync_threshold" ) == 50_000
373373
374374
375+ def test_get_collection_create_true_is_idempotent (tmp_path ):
376+ """Calling get_collection(create=True) twice on the same name must not crash.
377+
378+ ChromaDB 1.5.x's Rust bindings SIGSEGV when get_or_create_collection is
379+ called with metadata that differs from the stored collection metadata. The
380+ fix splits the call into get_collection -> fallback create_collection so the
381+ metadata-comparison codepath in chromadb_rust_bindings is never reached for
382+ existing collections. Regression guard for issue #1089.
383+ """
384+ palace = str (tmp_path / "palace" )
385+ backend = ChromaBackend ()
386+ backend .get_collection (palace , collection_name = "mempalace_drawers" , create = True )
387+ col2 = backend .get_collection (palace , collection_name = "mempalace_drawers" , create = True )
388+ assert isinstance (col2 , ChromaCollection )
389+
390+
391+ def test_get_collection_create_true_preserves_existing_metadata (tmp_path ):
392+ """Existing collection metadata is not overwritten when reopened with create=True."""
393+ palace = str (tmp_path / "palace" )
394+ backend = ChromaBackend ()
395+ backend .get_collection (palace , collection_name = "mempalace_drawers" , create = True )
396+ col = backend .get_collection (palace , collection_name = "mempalace_drawers" , create = True )
397+ assert col ._collection .metadata ["hnsw:space" ] == "cosine"
398+ assert col ._collection .metadata .get ("hnsw:batch_size" ) == 50_000
399+
400+
375401def test_fix_blob_seq_ids_converts_blobs_to_integers (tmp_path ):
376402 """Simulate a ChromaDB 0.6.x database with BLOB seq_ids and verify repair."""
377403 db_path = tmp_path / "chroma.sqlite3"
0 commit comments