pathwaycom/pathway · error · TypeError

SchemaRegistrySettings.headers[{i}] must be a SchemaRegistry

Error message

SchemaRegistrySettings.headers[{i}] must be a SchemaRegistryHeader instance, got {type(header).__name__}. Use pw.io.kafka.SchemaRegistryHeader(key=..., value=...).

What it means

SchemaRegistrySettings.headers must be a list of SchemaRegistryHeader instances (a small key/value dataclass), not raw strings, tuples, or dicts. The registry client accesses header.key and header.value attributes to build HTTP headers, so any other element type is rejected with a TypeError in __post_init__. The message tells you to construct entries with pw.io.kafka.SchemaRegistryHeader(key=..., value=...).

Source

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

                )
        if self.password is not None and self.username is None:
            raise ValueError(
                "SchemaRegistrySettings: 'password' was provided without "
                "'username'. Both are needed for username/password "
                "authentication."
            )
        if self.token_authorization is not None and (
            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

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Wrap each header in SchemaRegistryHeader: headers=[pw.io.kafka.SchemaRegistryHeader(key='x-tenant', value='acme')].
  2. Convert tuple/dict headers at the boundary: [SchemaRegistryHeader(k, v) for k, v in raw].
  3. Positional construction also works: SchemaRegistryHeader('x-tenant', 'acme').

Example fix

# before
settings = pw.io.kafka.SchemaRegistrySettings(
    urls=["http://registry:8081"],
    headers=[{"key": "x-tenant-id", "value": "42"}],
)

# after
from pathway.io.kafka import SchemaRegistryHeader
settings = pw.io.kafka.SchemaRegistrySettings(
    urls=["http://registry:8081"],
    headers=[SchemaRegistryHeader(key="x-tenant-id", value="42")],
)
Defensive patterns

Strategy: validation

Validate before calling

from pathway.io.kafka import SchemaRegistryHeader

raw_headers = [("x-tenant-id", "42"), ("x-trace", "abc")]
headers = [SchemaRegistryHeader(key=k, value=v) for k, v in raw_headers]
settings = pw.io.kafka.SchemaRegistrySettings(urls=urls, headers=headers)

Type guard

def is_header_list(headers) -> bool:
    from pathway.io.kafka import SchemaRegistryHeader
    return headers is None or all(
        isinstance(h, SchemaRegistryHeader) for h in headers
    )

Prevention

When it happens

Trigger: SchemaRegistrySettings(urls=[...], headers=[('x-tenant', 'acme')]) or headers=['x-tenant: acme'] or headers=[{'key': 'x-tenant', 'value': 'acme'}]; passing headers captured from another library (requests-style dict or tuple list).

Common situations: Reusing header formats from requests/httpx (dicts or tuple pairs) in Pathway Kafka settings; serializing headers to JSON and loading them back as dicts; porting code from confluent-kafka-python where headers are tuple pairs.

Related errors


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