{"record":{"id":"f594d4f45a49086e","repo":"JuliusBrussee/caveman","slug":"unsupported-adapter-diagnostic","errorCode":null,"errorMessage":"Unsupported adapter diagnostic","messagePattern":"Unsupported adapter diagnostic","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/sdk/python/caveman_cloud/middleware/runtime.py","lineNumber":340,"sourceCode":"            self._closed = True\n            if self._async_view is not None:\n                self._async_view._shutdown_now()\n            if self._receipt_pool is not None:\n                self._receipt_pool.shutdown(wait=False, cancel_futures=True)\n            self._caps = None\n            for connection in tuple(self._connections):\n                connection.close()\n\n    def __enter__(self):\n        return self\n\n    def __exit__(self, *_):\n        self.close()\n\n    def decline(self, reason: str) -> Optimization:\n        \"\"\"Report an untested native framework without sending content or I/O.\"\"\"\n        if reason != \"unsupported_version\":\n            raise ValueError(\"Unsupported adapter diagnostic\")\n        if self.mode == \"off\":\n            return Optimization(\"off\", \"disabled\", (), None, None, \"off\")\n        return self._bypass(reason)\n\n    def _bypass(self, code: str, diagnostic: bool = True) -> Optimization:\n        if diagnostic and self._diagnostic:\n            try:\n                self._diagnostic({\"code\": code, \"cache_continuity\": \"unavailable\"})\n            except Exception:\n                pass\n        if self.strict and diagnostic:\n            raise MiddlewareError(code)\n        return Optimization(\"bypassed\", code)\n\n    def _http(self, path: str, body: str | None, timeout: float) -> Any:\n        if self._closed:\n            raise MiddlewareError(\"closed\")\n        headers = {\"Content-Type\": \"application/json\"}","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/sdk/python/caveman_cloud/middleware/runtime.py#L322-L358","documentation":"decline(reason) only accepts the literal reason \"unsupported_version\"; any other string raises ValueError(\"Unsupported adapter diagnostic\"). This restricts decline() to its intended use: reporting an untested native framework version without sending content or I/O.","triggerScenarios":"Calling decline() with any string other than \"unsupported_version\", e.g. decline(\"timeout\"), decline(\"not_applicable\"), or a typo like \"unsupported_version\".","commonSituations":"Adapter authors wiring arbitrary failure reasons into decline(); renaming reason constants after an SDK upgrade; mixing up decline() with the general bypass path.","solutions":["Pass exactly the string \"unsupported_version\".","For other outcomes use the appropriate API (e.g. let optimize() run or handle its errors) rather than decline().","Define a constant ADAPTER_UNSUPPORTED_VERSION = \"unsupported_version\" and reuse it to avoid typos."],"exampleFix":"// before\nruntime.decline(\"too old\")  # ValueError\n// after\nruntime.decline(\"unsupported_version\")","handlingStrategy":"validation","validationCode":"ADAPTER_UNSUPPORTED_VERSION = \"unsupported_version\"\ndef decline_safe(rt, reason):\n    return rt.decline(reason) if reason == \"unsupported_version\" else None","typeGuard":"def is_adapter_decline_reason(reason) -> bool:\n    return reason == \"unsupported_version\"","tryCatchPattern":"try:\n    opt = rt.decline(reason)\nexcept ValueError:\n    opt = rt.decline(\"unsupported_version\")  # only valid reason","preventionTips":["Use a named constant instead of a raw string for the only accepted reason.","Never pipe generic error reasons into decline().","Add a unit test asserting decline() rejects non-\"unsupported_version\" values."],"tags":["invalid-argument","api-misuse","python"],"backgroundTag":"invalid-enum-value","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"}