Skip to content

Bug: _store_problem_to_chromadb uses threading with async collection — coroutine never awaited #2017

@mrveiss

Description

@mrveiss

Problem

`autobot-backend/api/codebase_analytics/scanner.py:695` — `_store_problem_to_chromadb()` wraps an async collection method in a thread executor:

```python
await _run_in_indexing_thread(
lambda: collection.add(
ids=[...],
documents=[...],
metadatas=[...],
)
)
```

If `collection` is an async ChromaDB collection (from `get_or_create_collection` on an async client), then `collection.add()` returns a coroutine, not the actual result. The lambda executes in a thread pool via `run_in_executor`, which calls the lambda and gets back the coroutine object — but never `await`s it. The data is silently never stored.

Discovered During

Working on #1712 (analytics empty sections investigation).

Current Impact

Low — This function appears to be unused in current code paths. The batch version `_store_problems_batch_to_chromadb()` (line 775) correctly uses `await collection.upsert()` and is what the scan pipeline actually calls. However, the individual function remains as dead/broken code that could cause silent data loss if called.

Fix

Either:

  1. Remove the function if truly unused
  2. Fix to use `await collection.add()` directly instead of threading

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions