Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(storage): avoid false mv not found errors (#2074)

Qin Haojie57339f2dbbb9
diff --git a/openviking/server/error_mapping.py b/openviking/server/error_mapping.py
index 68be4dd22..893c337f1 100644
--- a/openviking/server/error_mapping.py
+++ b/openviking/server/error_mapping.py
@@ -9,6 +9,7 @@ from openviking.pyagfs.exceptions import (
AGFSClientError,
AGFSConnectionError,
AGFSHTTPError,
+ AGFSNotFoundError,
AGFSTimeoutError,
)
from openviking.storage.errors import LockAcquisitionError, ResourceBusyError
@@ -366,6 +367,8 @@ def _map_upstream_api_error(exc: Exception) -> OpenVikingError | None:
def is_not_found_error(exc: Exception) -> bool:
if isinstance(exc, FileNotFoundError):
return True
+ if isinstance(exc, AGFSNotFoundError):
+ return True
if isinstance(exc, AGFSHTTPError) and exc.status_code == 404:
return True
message = str(exc).lower()
diff --git a/openviking/storage/viking_fs.py b/openviking/storage/viking_fs.py
index 71eabfaa4..615d79a37 100644
--- a/openviking/storage/viking_fs.py
+++ b/openviking/storage/viking_fs.py
@@ -551,12 +551,17 @@ class VikingFS:
new_path = self._uri_to_path(new_uri, ctx=ctx)
target_uri = self._path_to_uri(old_path, ctx=ctx)
- # Verify source exists and determine type before locking
+ # Verify source exists and determine type before locking.
try:
stat = await self._run_in_threadpool(self.agfs.stat, old_path)
is_dir = stat.get("isDir", False) if isinstance(stat, dict) else False
- except Exception:
- raise FileNotFoundError(f"mv source not found: {old_uri}")
+ except Exception as exc:
+ if not is_not_found_error(exc):
+ mapped = map_exception(exc, resource=old_uri)
+ if mapped is not None:
+ raise mapped from exc
+ raise
+ raise FileNotFoundError(f"mv source not found: {old_uri}") from exc
lock_context = (
LockContext(