pathwaycom/pathway · error · ValueError
'value' and format='{format}' cannot be set at the same time
Error message
'value' and format='{format}' cannot be set at the same time What it means
Raised by MessageQueueOutputFormat.build when 'value' is passed together with format='json' or format='dsv'. In those formats the writer serializes the whole table row (all columns) into the payload, so designating a single value column is contradictory; 'value' is only meaningful for 'raw'/'plaintext', which send exactly one column's bytes.
Source
Thrown at python/pathway/io/_utils.py:538
"headers (pathway_time / pathway_diff) and cannot be "
"used as a user header name. Alias the column to "
"another name with `table.select(<new_name>=...)`."
)
if header.name in header_fields:
raise ValueError(
f"Duplicate header name {header.name!r}: two columns "
"produce a header with the same name. Alias one of "
"them to a different name (e.g. via `table.select(...)`) "
"to keep both as separate Kafka headers."
)
header_fields[header.name] = cls.add_column_reference_to_extract(
header, columns_to_extract, extracted_field_indices
)
# Format-dependent parts: handle json and dsv separately
if format == "json" or format == "dsv":
if value is not None:
raise ValueError(
f"'value' and format='{format}' cannot be set at the same time"
)
if format == "json":
reserved = {"time", "diff"}
conflicting = reserved.intersection(table._columns.keys())
if conflicting:
raise ValueError(
f"The table has columns {sorted(conflicting)} which "
f"clash with the reserved JSON fields written by the "
f"connector ('time', 'diff'). Rename or drop the "
f"conflicting column(s) before writing in 'json' "
f"format, otherwise the output JSON would contain "
f"duplicate keys."
)
for column_name in table._columns:
cls.add_column_reference_to_extract(
table[column_name], columns_to_extract, extracted_field_indices
)View on GitHub (pinned to fa2f74a464)
Solutions
- Remove the 'value' argument when format='json' or 'dsv' (all columns are serialized automatically).
- If only some columns should be emitted, table.select() the desired columns first.
- If you truly want a single column as the raw payload, use format='raw' with value=.
Example fix
# before pw.io.kafka.write(t, ..., format='json', value=pw.this.payload) # after t = t.select(pw.this.payload) # if only that column is wanted pw.io.kafka.write(t, ..., format='json')
Defensive patterns
Strategy: validation
Validate before calling
if format in ('json', 'dsv'):
assert value is None, "'value' cannot be combined with json/dsv output formats" Try / catch
try:
pw.io.kafka.write(t, ..., format=format, value=value)
except ValueError as e:
if "cannot be set at the same time" in str(e):
pw.io.kafka.write(t, ..., format=format)
else:
raise Prevention
- Split sink config builders by format family (structured vs raw).
- When migrating raw -> json, audit every raw-only argument (value, and note key handling).
When it happens
Trigger: pw.io.kafka.write(t, ..., format='json', value=pw.this.payload); switching a raw writer to json while keeping the value argument; reusing a kwargs dict between raw and json writers.
Common situations: Gradually migrating a raw-payload writer to structured json output and leaving the old value= behind; copy-paste between sink configurations.
Related errors
- Unsupported argument for {data_format!r} format: 'value'
- 'schema_registry_settings' is only meaningful for the 'json'
- Unsupported format: {format}
- The sort_by column {column.name!r} is not part of the data b
- Failed to install dependencies
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/b25a68d49105c2da.
Report an issue: GitHub.