pathwaycom/pathway · error · ValueError

SchemaRegistrySettings.urls[{i}] must be a non-empty string;

Error message

SchemaRegistrySettings.urls[{i}] must be a non-empty string; got {url!r}.

What it means

SchemaRegistrySettings validates every entry of the 'urls' list in its __post_init__. Each element must be a non-empty string. This error fires when one element is either not a str at all (e.g. an int, None, bytes) or is the empty string ''. The settings object is used to configure the Confluent Schema Registry connection for pw.io.kafka connectors, and an invalid URL entry would break every HTTP request, so it is rejected eagerly at construction time.

Source

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

    headers: list[SchemaRegistryHeader] | None = None
    proxy: str | None = None
    timeout: datetime.timedelta | None = None

    def __post_init__(self):
        if not isinstance(self.urls, (list, tuple)):
            raise TypeError(
                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

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Inspect the reported index urls[i] and fix or remove the offending entry.
  2. If URLs come from config, filter blanks before construction: urls=[u for u in raw_urls if u].
  3. Ensure every element is a plain Python str (wrap or str()-convert parsed values).
  4. Fall back to a sensible default URL when the config value is empty.

Example fix

# before
settings = pw.io.kafka.SchemaRegistrySettings(
    urls=os.environ.get("SCHEMA_REGISTRY_URL", "").split(",")
)

# after
raw = [u.strip() for u in os.environ.get("SCHEMA_REGISTRY_URL", "").split(",")]
settings = pw.io.kafka.SchemaRegistrySettings(
    urls=[u for u in raw if u]
)
Defensive patterns

Strategy: validation

Validate before calling

def clean_registry_urls(raw) -> list[str]:
    if isinstance(raw, str):
        raw = [raw]
    urls = [u.strip() for u in raw or []]
    bad = [(i, u) for i, u in enumerate(urls) if not isinstance(u, str) or not u]
    if bad:
        raise ValueError(f"invalid registry urls at {bad}")
    return urls

urls = clean_registry_urls(os.environ.get("SCHEMA_REGISTRY_URL", "").split(","))
settings = pw.io.kafka.SchemaRegistrySettings(urls=urls)

Type guard

def is_valid_url_list(urls) -> bool:
    return (
        isinstance(urls, (list, tuple))
        and len(urls) > 0
        and all(isinstance(u, str) and u for u in urls)
    )

Prevention

When it happens

Trigger: Constructing SchemaRegistrySettings(urls=['']) or urls=['http://registry:8081', None] or urls=[8081]. Also triggered by URLs read from config/env where an unset variable produced '' (e.g. os.environ.get('REGISTRY_URL', '')), or by parsing a delimited string like env.split(',') which yields '' when the env var is empty.

Common situations: Loading registry URLs from environment variables or YAML config where a missing value becomes an empty string; copy-pasting a URL list with a trailing comma; passing a port number or parsed URL object instead of a string.

Related errors


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