pathwaycom/pathway · error · ValueError
'value' must be specified if 'key' is not None
Error message
'value' must be specified if 'key' is not None
What it means
Raised by MessageQueueOutputFormat.build for format='raw' or 'plaintext' when a 'key' column is given but 'value' is None. In raw/plaintext mode the message payload is exactly one designated column; when key is set you must say which column carries the payload too, because there is no unambiguous default in the presence of a key (the single-column auto-detection is only attempted when key is None).
Source
Thrown at python/pathway/io/_utils.py:571
for column_name in table._columns:
cls.add_column_reference_to_extract(
table[column_name], columns_to_extract, extracted_field_indices
)
table = table.select(*columns_to_extract)
data_format = api.DataFormat(
format_type="jsonlines" if format == "json" else "dsv",
key_field_names=[],
value_fields=_format_output_value_fields(table),
delimiter=delimiter,
schema_registry_settings=maybe_schema_registry_settings(
schema_registry_settings
),
subject=subject,
)
elif format == "raw" or format == "plaintext":
value_field_index = None
if key is not None and value is None:
raise ValueError("'value' must be specified if 'key' is not None")
if value is not None:
value_field_index = cls.add_column_reference_to_extract(
value, columns_to_extract, extracted_field_indices
)
else:
column_names = list(table._columns.keys())
if len(column_names) != 1:
raise ValueError(
f"'{format}' format without explicit 'value' specification "
"can only be used with single-column tables"
)
value = table[column_names[0]]
value_field_index = cls.add_column_reference_to_extract(
value, columns_to_extract, extracted_field_indices
)
table = table.select(*columns_to_extract)
if (View on GitHub (pinned to fa2f74a464)
Solutions
- Pass value=pw.this.payload alongside key=pw.this.k.
- Or drop 'key' if keying is not needed and the table is single-column (auto-detection then applies).
Example fix
# before pw.io.kafka.write(t, ..., format='raw', key=pw.this.k) # after pw.io.kafka.write(t, ..., format='raw', key=pw.this.k, value=pw.this.payload)
Defensive patterns
Strategy: validation
Validate before calling
if format in ('raw', 'plaintext') and key is not None:
assert value is not None, "raw/plaintext output with a key requires an explicit value column" Try / catch
try:
pw.io.kafka.write(t, ..., format='raw', key=pw.this.k)
except ValueError as e:
if "'value' must be specified" in str(e):
pw.io.kafka.write(t, ..., format='raw', key=pw.this.k, value=pw.this.payload)
else:
raise Prevention
- Always pass key and value together for raw sinks.
- Review raw-sink configs whenever adding key routing.
When it happens
Trigger: pw.io.kafka.write(t, ..., format='raw', key=pw.this.k) with no value on a multi-column table; copying key= from a json-format writer into a raw-format one.
Common situations: Keyed raw payloads (e.g. keyed binary blobs) where the author assumed the writer would guess the payload column; gradual addition of key= to an existing raw writer.
Related errors
- '{format}' format without explicit 'value' specification can
- The value column must have one of the following types: {allo
- Failed to install dependencies
- Column {pseudocolumn} has to contain integers only.
- Column {api.TIME_PSEUDOCOLUMN} cannot contain negative times
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/6664c12ec47cf8c1.
Report an issue: GitHub.