{"record":{"id":"8d2533bad30bae53","repo":"pathwaycom/pathway","slug":"schemaregistrysettings-timeout-must-be-a-datetime","errorCode":null,"errorMessage":"SchemaRegistrySettings.timeout must be a datetime.timedelta, got {type(self.timeout).__name__}.","messagePattern":"SchemaRegistrySettings\\.timeout must be a datetime\\.timedelta, got (.+?)\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/_io_helpers.py","lineNumber":322,"sourceCode":"            self.username is not None or self.password is not None\n        ):\n            raise ValueError(\n                \"SchemaRegistrySettings: 'token_authorization' is mutually \"\n                \"exclusive with 'username'/'password'. Pick one \"\n                \"authentication method.\"\n            )\n        if self.headers is not None:\n            for i, header in enumerate(self.headers):\n                if not isinstance(header, SchemaRegistryHeader):\n                    raise TypeError(\n                        f\"SchemaRegistrySettings.headers[{i}] must be a \"\n                        f\"SchemaRegistryHeader instance, got \"\n                        f\"{type(header).__name__}. Use \"\n                        f\"pw.io.kafka.SchemaRegistryHeader(key=..., value=...).\"\n                    )\n        if self.timeout is not None:\n            if not isinstance(self.timeout, datetime.timedelta):\n                raise TypeError(\n                    f\"SchemaRegistrySettings.timeout must be a \"\n                    f\"datetime.timedelta, got {type(self.timeout).__name__}.\"\n                )\n            if self.timeout <= datetime.timedelta(0):\n                raise ValueError(\n                    f\"SchemaRegistrySettings: 'timeout' must be a positive \"\n                    f\"duration; got {self.timeout!r}.\"\n                )\n\n    @property\n    def to_engine(self):\n        return api.SchemaRegistrySettings(\n            self.urls,\n            token_authorization=self.token_authorization,\n            username=self.username,\n            password=self.password,\n            headers=[(header.key, header.value) for header in self.headers or []],\n            proxy=self.proxy,","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/_io_helpers.py#L304-L340","documentation":"The 'timeout' field of SchemaRegistrySettings must be a datetime.timedelta, not a number. Unlike many HTTP libraries that accept bare seconds as float/int, Pathway models durations as timedeltas so that units are explicit. Passing an int or float raises this TypeError in __post_init__ before any network activity starts.","triggerScenarios":"SchemaRegistrySettings(urls=[...], timeout=30) or timeout=0.5; forwarding a timeout value configured for requests/httpx (numeric seconds) directly into Pathway settings; reading a 'timeout_seconds' key from YAML and passing it unconverted.","commonSituations":"Sharing one timeout constant between a requests client and the Pathway registry settings; copy-pasting examples from other Kafka libraries that take numeric timeouts; docstring says 'in seconds' which invites passing a plain number.","solutions":["Wrap the value: timeout=datetime.timedelta(seconds=30).","Convert at the config boundary if your config stores seconds.","Omit timeout entirely if the default is acceptable."],"exampleFix":"# before\nsettings = pw.io.kafka.SchemaRegistrySettings(\n    urls=[\"http://registry:8081\"],\n    timeout=30,\n)\n\n# after\nimport datetime\nsettings = pw.io.kafka.SchemaRegistrySettings(\n    urls=[\"http://registry:8081\"],\n    timeout=datetime.timedelta(seconds=30),\n)","handlingStrategy":"type-guard","validationCode":"import datetime\n\nraw_timeout = cfg.get(\"registry_timeout_seconds\", 30)\ntimeout = raw_timeout if isinstance(raw_timeout, datetime.timedelta) else datetime.timedelta(seconds=raw_timeout)\nsettings = pw.io.kafka.SchemaRegistrySettings(urls=urls, timeout=timeout)","typeGuard":"import datetime\n\ndef is_timedelta(v) -> bool:\n    return isinstance(v, datetime.timedelta)","tryCatchPattern":null,"preventionTips":["Always wrap timeout in datetime.timedelta(seconds=...) — Pathway does not accept bare numbers.","Store timeouts in config as seconds and convert in exactly one place.","Do not reuse a numeric timeout constant across requests/httpx and Pathway settings."],"tags":["kafka","schema-registry","type-error","timeout"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}