pathwaycom/pathway · error · TypeError

SchemaRegistrySettings.{field_name} must be a str, got {type

Error message

SchemaRegistrySettings.{field_name} must be a str, got {type(value).__name__}.

What it means

SchemaRegistrySettings.__post_init__ type-checks the optional string fields token_authorization, username, password, and proxy. If any of them is set to a non-None, non-str value (int, bytes, dict, etc.) a TypeError is raised naming the offending field and its actual type. The registry client sends these values verbatim in HTTP headers, so non-string values would fail later at the network layer; validation catches this at construction.

Source

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

                f"SchemaRegistrySettings.urls must be a list of strings, "
                f"got {type(self.urls).__name__}. Wrap a single URL in a "
                f"list: urls=['http://...']."
            )
        if not self.urls:
            raise ValueError(
                "SchemaRegistrySettings requires at least one entry in 'urls'; "
                "got an empty list."
            )
        for i, url in enumerate(self.urls):
            if not isinstance(url, str) or not url:
                raise ValueError(
                    f"SchemaRegistrySettings.urls[{i}] must be a non-empty "
                    f"string; got {url!r}."
                )
        for field_name in ("token_authorization", "username", "password", "proxy"):
            value = getattr(self, field_name)
            if value is not None and not isinstance(value, str):
                raise TypeError(
                    f"SchemaRegistrySettings.{field_name} must be a str, "
                    f"got {type(value).__name__}."
                )
        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:

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Convert the offending field to str before construction, e.g. username=str(user_id).
  2. If using pydantic SecretStr, unwrap it with .get_secret_value().
  3. Decode bytes credentials with .decode('utf-8').
  4. Move the value to the correct parameter (e.g. numeric timeout belongs in timeout=timedelta).

Example fix

# before
settings = pw.io.kafka.SchemaRegistrySettings(
    urls=["http://registry:8081"],
    username=os.environb.get(b"REGISTRY_USER"),  # bytes
)

# after
settings = pw.io.kafka.SchemaRegistrySettings(
    urls=["http://registry:8081"],
    username=os.environb.get(b"REGISTRY_USER", b"").decode("utf-8"),
)
Defensive patterns

Strategy: type-guard

Validate before calling

auth_fields = {"token_authorization": token, "username": user, "password": pwd, "proxy": proxy}
for name, value in auth_fields.items():
    if value is not None and not isinstance(value, str):
        auth_fields[name] = str(value)
settings = pw.io.kafka.SchemaRegistrySettings(urls=urls, **auth_fields)

Type guard

def auth_fields_are_str(**fields) -> bool:
    return all(v is None or isinstance(v, str) for v in fields.values())

Prevention

When it happens

Trigger: Passing schema_registry_settings=SchemaRegistrySettings(urls=[...], username=user_id) where user_id is an int; passing password=bytes from os.environb; passing a token object or SecretStr instead of a str; passing timeout-like numeric values into proxy.

Common situations: Reading credentials from typed config objects (pydantic models,SecretStr), from JSON where a credential is accidentally numeric (e.g. username 12345), or passing bytes from environment access without decoding.

Related errors


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