fix(retrieval): fail open on registry resolution errors
This commit is contained in:
@@ -163,6 +163,45 @@ def test_ingest_file_derives_project_id_from_registry_root(tmp_data_dir, tmp_pat
|
||||
assert all(meta["project_id"] == "p04-gigabit" for meta in fake_store.metadatas)
|
||||
|
||||
|
||||
def test_ingest_file_logs_and_fails_open_when_project_derivation_fails(
|
||||
tmp_data_dir,
|
||||
sample_markdown,
|
||||
monkeypatch,
|
||||
):
|
||||
"""A broken registry should be visible but should not block ingestion."""
|
||||
init_db()
|
||||
warnings = []
|
||||
|
||||
class FakeVectorStore:
|
||||
def __init__(self):
|
||||
self.metadatas = []
|
||||
|
||||
def add(self, ids, documents, metadatas):
|
||||
self.metadatas.extend(metadatas)
|
||||
|
||||
def delete(self, ids):
|
||||
return None
|
||||
|
||||
fake_store = FakeVectorStore()
|
||||
monkeypatch.setattr("atocore.ingestion.pipeline.get_vector_store", lambda: fake_store)
|
||||
monkeypatch.setattr(
|
||||
"atocore.projects.registry.derive_project_id_for_path",
|
||||
lambda path: (_ for _ in ()).throw(ValueError("registry broken")),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"atocore.ingestion.pipeline.log.warning",
|
||||
lambda event, **kwargs: warnings.append((event, kwargs)),
|
||||
)
|
||||
|
||||
result = ingest_file(sample_markdown)
|
||||
|
||||
assert result["status"] == "ingested"
|
||||
assert fake_store.metadatas
|
||||
assert all(meta["project_id"] == "" for meta in fake_store.metadatas)
|
||||
assert warnings[0][0] == "project_id_derivation_failed"
|
||||
assert "registry broken" in warnings[0][1]["error"]
|
||||
|
||||
|
||||
def test_ingest_project_folder_passes_project_id_to_files(tmp_data_dir, sample_folder, monkeypatch):
|
||||
seen = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user