[Bug]: HttpCollection.fetch_data key mismatch causes update_uri_mapping to always fail
Bug Description
HttpCollection.fetch_data() always returns an empty FetchDataInCollectionResult when communicating with a remote vikingdb server (e.g., a separate pod), causing update_uri_mapping() to fail for all records.
Root Cause
The server-side /api/vikingdb/data/fetch_in_collection endpoint serializes the response using asdict(FetchDataInCollectionResult) (api_fastapi.py:258), which produces the JSON key "items" — matching the dataclass field name:
@dataclass
class FetchDataInCollectionResult:
items: List[DataItem] = field(default_factory=list)
ids_not_exist: List[Any] = field(default_factory=list)
However, the client-side HttpCollection.fetch_data() (http_collection.py:304) looks for the key "fetch" when parsing the response:
if isinstance(data, dict):
if "fetch" in data: # ← should be "items"
fetch = data.get("fetch", [])
Since "fetch" never exists in the response, fetch_result.items stays empty, causing get() → update_uri_mapping() to fail.
Impact
- 244
update_uri_mapping failed to fetch full recordswarnings in a typicaladd_resourcesession - All L0/L1/L2 vector embeddings retain
viking://temp/...URIs instead of being renamed toviking://resources/... - L0/L1 are eventually recovered by the parent refresh mechanism
- L2 is skipped in the incremental update path (
content_changed=False), making file-level embeddings permanently missing until manualreindex
Why It Wasn't Caught Before
In local/embedded mode, base.py:get() uses isinstance(result, FetchDataInCollectionResult) to match the Python object directly — it never goes through JSON serialization, so the "fetch" typo in the HTTP client was never triggered. The bug only surfaces when the vectorDB is separated into a remote service (HTTP mode).
Fix
One-line change in http_collection.py:304:
- if "fetch" in data:
- fetch = data.get("fetch", [])
+ if "items" in data:
+ fetch = data.get("items", [])
Environment
- OpenViking deployed with vikingdb as a separate Kubernetes pod
- HTTP adapter (
HttpCollectionAdapter) for vectorDB communication