pathwaycom/pathway · error · TypeError

SchemaRegistrySettings.timeout must be a datetime.timedelta,

Error message

SchemaRegistrySettings.timeout must be a datetime.timedelta, got {type(self.timeout).__name__}.

What it means

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.

Source

Thrown at python/pathway/internals/_io_helpers.py:322

            self.username is not None or self.password is not None
        ):
            raise ValueError(
                "SchemaRegistrySettings: 'token_authorization' is mutually "
                "exclusive with 'username'/'password'. Pick one "
                "authentication method."
            )
        if self.headers is not None:
            for i, header in enumerate(self.headers):
                if not isinstance(header, SchemaRegistryHeader):
                    raise TypeError(
                        f"SchemaRegistrySettings.headers[{i}] must be a "
                        f"SchemaRegistryHeader instance, got "
                        f"{type(header).__name__}. Use "
                        f"pw.io.kafka.SchemaRegistryHeader(key=..., value=...)."
                    )
        if self.timeout is not None:
            if not isinstance(self.timeout, datetime.timedelta):
                raise TypeError(
                    f"SchemaRegistrySettings.timeout must be a "
                    f"datetime.timedelta, got {type(self.timeout).__name__}."
                )
            if self.timeout <= datetime.timedelta(0):
                raise ValueError(
                    f"SchemaRegistrySettings: 'timeout' must be a positive "
                    f"duration; got {self.timeout!r}."
                )

    @property
    def to_engine(self):
        return api.SchemaRegistrySettings(
            self.urls,
            token_authorization=self.token_authorization,
            username=self.username,
            password=self.password,
            headers=[(header.key, header.value) for header in self.headers or []],
            proxy=self.proxy,

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Wrap the value: timeout=datetime.timedelta(seconds=30).
  2. Convert at the config boundary if your config stores seconds.
  3. Omit timeout entirely if the default is acceptable.

Example fix

# before
settings = pw.io.kafka.SchemaRegistrySettings(
    urls=["http://registry:8081"],
    timeout=30,
)

# after
import datetime
settings = pw.io.kafka.SchemaRegistrySettings(
    urls=["http://registry:8081"],
    timeout=datetime.timedelta(seconds=30),
)
Defensive patterns

Strategy: type-guard

Validate before calling

import datetime

raw_timeout = cfg.get("registry_timeout_seconds", 30)
timeout = raw_timeout if isinstance(raw_timeout, datetime.timedelta) else datetime.timedelta(seconds=raw_timeout)
settings = pw.io.kafka.SchemaRegistrySettings(urls=urls, timeout=timeout)

Type guard

import datetime

def is_timedelta(v) -> bool:
    return isinstance(v, datetime.timedelta)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15). Data as JSON: /api/errors/8d2533bad30bae53. Report an issue: GitHub.