{"record":{"id":"7c84c5222c2d90f9","repo":"HKUDS/Vibe-Trading","slug":"no-supported-file-lock-backend-for-codex-oauth-ref","errorCode":null,"errorMessage":"No supported file-lock backend for Codex OAuth refresh","messagePattern":"No supported file-lock backend for Codex OAuth refresh","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/src/providers/openai_codex.py","lineNumber":142,"sourceCode":"    except OSError:\n        pass\n\n\ndef _lock_token_file(handle: Any) -> None:\n    \"\"\"Acquire a cross-process lock on an opened token lock file.\"\"\"\n    if fcntl is not None:\n        fcntl.flock(handle.fileno(), fcntl.LOCK_EX)\n        return\n    if msvcrt is not None:  # pragma: no cover - exercised with a platform mock.\n        handle.seek(0, os.SEEK_END)\n        if handle.tell() == 0:\n            handle.write(b\"\\0\")\n            handle.flush()\n            os.fsync(handle.fileno())\n        handle.seek(0)\n        msvcrt.locking(handle.fileno(), msvcrt.LK_LOCK, 1)\n        return\n    raise RuntimeError(\"No supported file-lock backend for Codex OAuth refresh\")\n\n\ndef _unlock_token_file(handle: Any) -> None:\n    \"\"\"Release the lock acquired by :func:`_lock_token_file`.\"\"\"\n    if fcntl is not None:\n        fcntl.flock(handle.fileno(), fcntl.LOCK_UN)\n        return\n    if msvcrt is not None:  # pragma: no cover - exercised with a platform mock.\n        handle.seek(0)\n        msvcrt.locking(handle.fileno(), msvcrt.LK_UNLCK, 1)\n\n\n@contextmanager\ndef _codex_refresh_lock(storage: Any) -> Iterator[None]:\n    \"\"\"Serialize refresh-token rotation across threads and processes.\"\"\"\n    lock_path = storage.get_token_path().with_name(f\"{storage.get_token_path().name}.lock\")\n    lock_path.parent.mkdir(parents=True, exist_ok=True)\n    with _TOKEN_REFRESH_THREAD_LOCK:","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/providers/openai_codex.py#L124-L160","documentation":"_lock_token_file provides cross-process locking for Codex OAuth refresh using fcntl (POSIX) or msvcrt (Windows); if neither module is available, no file-lock backend exists and refresh cannot be safely serialized, so it raises.","triggerScenarios":"Running on a platform where both fcntl and msvcrt are None (e.g. some restricted WASM/embedded/non-standard Python builds) during a Codex token refresh that needs the lock.","commonSituations":"Exotic or sandboxed Python runtimes without OS locking primitives; a stubbed-out platform layer in tests; Python builds for platforms lacking fcntl support.","solutions":["Run on a standard CPython build for your OS (Linux/macOS provide fcntl; Windows provides msvcrt)","If in a sandbox, grant the runtime access to real file-locking syscalls","Check diagnostics: python -c \"import fcntl\" / python -c \"import msvcrt\" and switch runtime accordingly"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import sys\nif sys.platform not in ('linux', 'darwin', 'win32'):\n    raise SystemExit('Codex OAuth refresh requires a platform with fcntl or msvcrt')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Deploy the agent on standard CPython runtimes","Include a platform assertion in container entrypoints"],"tags":["oauth","file-locking","platform-support","codex"],"backgroundTag":"unsupported-platform","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}