{"record":{"id":"dad65fda0e227e97","repo":"JuliusBrussee/caveman","slug":"off-dad65f","errorCode":"off","errorMessage":"off","messagePattern":"off","errorType":"error_code","errorClass":"MiddlewareError","httpStatus":null,"severity":"warning","filePath":"packages/sdk/python/caveman_cloud/middleware/runtime.py","lineNumber":106,"sourceCode":"        self._failures = 0\n        self._open_until = 0.0\n        self._receipt_pool: ThreadPoolExecutor | None = None\n        self._receipt_slots = threading.BoundedSemaphore(16)\n        self._async_view = None\n\n    def as_async(self):\n        \"\"\"Cached bounded async view; close() releases its owned worker pool.\"\"\"\n        from .async_runtime import AsyncMiddlewareRuntime\n        with self._lock:\n            if self._closed:\n                raise MiddlewareError(\"closed\")\n            if self._async_view is None or self._async_view._closed:\n                self._async_view = AsyncMiddlewareRuntime.from_sync(self)\n            return self._async_view\n\n    def ready(self) -> dict:\n        if self.mode == \"off\":\n            raise MiddlewareError(\"off\")\n        value = validate.capabilities(self._http(\"capabilities\", None, self.deadline_ms / 1000))\n        with self._lock:\n            if self._closed:\n                raise MiddlewareError(\"closed\")\n            self._caps = value\n        return copy.deepcopy(value)\n\n    def preflight(self) -> PreflightReport:\n        \"\"\"Nonthrowing discovery, even in strict mode; sends no candidate content.\"\"\"\n        if self.mode == \"off\":\n            return _preflight_report(self.mode, \"disabled\")\n        try:\n            caps = self.ready()\n            reason = (\"record_only\" if self.mode == \"record\" or caps[\"mode\"] == \"record\"\n                      else \"recovery_unavailable\" if not caps[\"persistent\"] or not caps[\"recovery\"] else \"ready\")\n            return _preflight_report(self.mode, reason, caps)\n        except Exception as error:\n            with self._lock:","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/sdk/python/caveman_cloud/middleware/runtime.py#L88-L124","documentation":"ready() raises MiddlewareError(\"off\") when the runtime was constructed with mode=\"off\". In off mode the middleware is intentionally disabled: it performs no HTTP capability check and never reports ready. This is a configuration signal, not a network failure.","triggerScenarios":"Calling ready() (directly or via preflight()) on a runtime whose mode is \"off\".","commonSituations":"Middleware disabled via env/config for local dev or CI, then code that unconditionally calls ready(); stale config where the service was expected to be enabled.","solutions":["Check runtime.mode before calling ready(); skip readiness checks when mode == \"off\".","If the middleware should be active, reconfigure the runtime with mode set to \"on\"/\"strict\" (not \"off\").","Fix the environment/config source (env var, config file) that forced mode=\"off\"."],"exampleFix":"// before\nreport = runtime.ready()\n// after\nif runtime.mode != \"off\":\n    report = runtime.ready()\nelse:\n    report = None  # middleware intentionally disabled","handlingStrategy":"validation","validationCode":"def ready_safe(rt):\n    return rt.ready() if rt.mode != \"off\" else None","typeGuard":"def middleware_enabled(rt) -> bool:\n    return getattr(rt, \"mode\", \"off\") != \"off\"","tryCatchPattern":"try:\n    caps = rt.ready()\nexcept MiddlewareError as e:\n    if str(e) == \"off\":\n        caps = None  # middleware intentionally disabled\n    else:\n        raise","preventionTips":["Check runtime.mode before any readiness probing.","Centralize middleware enablement in one config flag and document that \"off\" disables ready().","Audit CI/dev configs that force mode=\"off\" so prod code paths account for it."],"tags":["configuration","middleware-disabled","python"],"backgroundTag":"feature-not-enabled","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}