pathwaycom/pathway · error · ValueError

{arg_name} must not be empty

Error message

{arg_name} must not be empty

What it means

This ValueError is raised by Pathway's MSSQL connector when an identifier argument (table_name or schema_name) passed to pw.io.mssql.read/write is an empty string. The connector validates identifiers up-front because an empty name would produce the illegal bracket-quoted identifier `[]`, which SQL Server rejects with an opaque parse error far from the call site. Failing at call time gives you a clear message pointing at the exact argument.

Source

Thrown at python/pathway/io/mssql/__init__.py:31

from pathway.internals.table import Table
from pathway.internals.table_io import table_from_datasource
from pathway.internals.trace import trace_user_frame
from pathway.io._utils import (
    SNAPSHOT_OUTPUT_TABLE_TYPE,
    get_column_index,
    init_mode_from_str,
    read_schema,
)


def _validate_identifier(arg_name: str, value: str) -> None:
    """Reject empty / NUL-containing identifiers up-front so users see a
    clear ``ValueError`` at call time instead of an opaque SQL Server parse
    error (`[]` is not a legal bracket-quoted identifier; embedded NUL
    bytes corrupt the TDS stream).
    """
    if value == "":
        raise ValueError(f"{arg_name} must not be empty")
    if "\0" in value:
        raise ValueError(f"{arg_name} must not contain NUL characters")


@check_arg_types
@trace_user_frame
def read(
    connection_string: str,
    table_name: str,
    schema: type[Schema],
    *,
    mode: Literal["static", "streaming"] = "streaming",
    schema_name: str = "dbo",
    autocommit_duration_ms: int | None = 1500,
    name: str | None = None,
    max_backlog_size: int | None = None,
    debug_data: Any = None,
) -> Table:

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Check the value of table_name (and schema_name) right before the call and fix the source of the empty string (missing env var, wrong config key, unassigned variable).
  2. If the table name comes from configuration, add a fail-fast assertion or startup check in your config loader so empty names are reported with context.
  3. As a last resort, supply a sensible default (e.g. schema_name="dbo") instead of an empty string.

Example fix

# before
table_name = os.environ.get("MSSQL_TABLE", "")
pw.io.mssql.read(conn_str, table_name, schema=MySchema)

# after
table_name = os.environ["MSSQL_TABLE"]  # KeyError at startup if unset
if not table_name:
    raise RuntimeError("MSSQL_TABLE must be set to a non-empty table name")
pw.io.mssql.read(conn_str, table_name, schema=MySchema)
Defensive patterns

Strategy: validation

Validate before calling

def require_non_empty(name: str, value: str) -> str:
    if value == "":
        raise RuntimeError(f"{name} must be a non-empty MSSQL identifier")
    return value

table_name = require_non_empty("table_name", os.environ.get("MSSQL_TABLE", ""))

Type guard

def is_valid_identifier(value: str) -> bool:
    return isinstance(value, str) and value != ""

Try / catch

try:
    pw.io.mssql.read(conn, table_name, schema=MySchema)
except ValueError as e:
    if "must not be empty" in str(e):
        raise RuntimeError(f"Bad MSSQL config: table_name={table_name!r}") from e
    raise

Prevention

When it happens

Trigger: Calling pw.io.mssql.read(connection_string, "", schema) or pw.io.mssql.write(table, "", ...) with table_name=""; also passing schema_name="" (the default is "dbo"). Typically happens when the table name is built from an empty variable, an unset environment value, or an f-string that renders to nothing.

Common situations: Reading table names from config/env vars that are missing in the deployed environment; refactoring code so the table-name variable is initialized but never assigned; copy-pasting a connector call and forgetting to fill in the table name.

Related errors


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