{"record":{"id":"91c795e534d22171","repo":"pathwaycom/pathway","slug":"arg-name-must-not-be-empty","errorCode":null,"errorMessage":"{arg_name} must not be empty","messagePattern":"(.+?) must not be empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/io/mssql/__init__.py","lineNumber":31,"sourceCode":"from pathway.internals.table import Table\nfrom pathway.internals.table_io import table_from_datasource\nfrom pathway.internals.trace import trace_user_frame\nfrom pathway.io._utils import (\n    SNAPSHOT_OUTPUT_TABLE_TYPE,\n    get_column_index,\n    init_mode_from_str,\n    read_schema,\n)\n\n\ndef _validate_identifier(arg_name: str, value: str) -> None:\n    \"\"\"Reject empty / NUL-containing identifiers up-front so users see a\n    clear ``ValueError`` at call time instead of an opaque SQL Server parse\n    error (`[]` is not a legal bracket-quoted identifier; embedded NUL\n    bytes corrupt the TDS stream).\n    \"\"\"\n    if value == \"\":\n        raise ValueError(f\"{arg_name} must not be empty\")\n    if \"\\0\" in value:\n        raise ValueError(f\"{arg_name} must not contain NUL characters\")\n\n\n@check_arg_types\n@trace_user_frame\ndef read(\n    connection_string: str,\n    table_name: str,\n    schema: type[Schema],\n    *,\n    mode: Literal[\"static\", \"streaming\"] = \"streaming\",\n    schema_name: str = \"dbo\",\n    autocommit_duration_ms: int | None = 1500,\n    name: str | None = None,\n    max_backlog_size: int | None = None,\n    debug_data: Any = None,\n) -> Table:","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/io/mssql/__init__.py#L13-L49","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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).","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.","As a last resort, supply a sensible default (e.g. schema_name=\"dbo\") instead of an empty string."],"exampleFix":"# before\ntable_name = os.environ.get(\"MSSQL_TABLE\", \"\")\npw.io.mssql.read(conn_str, table_name, schema=MySchema)\n\n# after\ntable_name = os.environ[\"MSSQL_TABLE\"]  # KeyError at startup if unset\nif not table_name:\n    raise RuntimeError(\"MSSQL_TABLE must be set to a non-empty table name\")\npw.io.mssql.read(conn_str, table_name, schema=MySchema)","handlingStrategy":"validation","validationCode":"def require_non_empty(name: str, value: str) -> str:\n    if value == \"\":\n        raise RuntimeError(f\"{name} must be a non-empty MSSQL identifier\")\n    return value\n\ntable_name = require_non_empty(\"table_name\", os.environ.get(\"MSSQL_TABLE\", \"\"))","typeGuard":"def is_valid_identifier(value: str) -> bool:\n    return isinstance(value, str) and value != \"\"","tryCatchPattern":"try:\n    pw.io.mssql.read(conn, table_name, schema=MySchema)\nexcept ValueError as e:\n    if \"must not be empty\" in str(e):\n        raise RuntimeError(f\"Bad MSSQL config: table_name={table_name!r}\") from e\n    raise","preventionTips":["Load and validate connector config at startup with explicit checks for empty strings.","Prefer failing fast on missing env vars (os.environ[...] with no default) over silently defaulting to empty.","Unit-test config loading with missing values so empty identifiers never reach the connector."],"tags":["mssql","validation","identifier","sql-server","pathway"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}