{"record":{"id":"b25a68d49105c2da","repo":"pathwaycom/pathway","slug":"value-and-format-format-cannot-be-set-at-the","errorCode":null,"errorMessage":"'value' and format='{format}' cannot be set at the same time","messagePattern":"'value' and format='(.+?)' cannot be set at the same time","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/io/_utils.py","lineNumber":538,"sourceCode":"                        \"headers (pathway_time / pathway_diff) and cannot be \"\n                        \"used as a user header name. Alias the column to \"\n                        \"another name with `table.select(<new_name>=...)`.\"\n                    )\n                if header.name in header_fields:\n                    raise ValueError(\n                        f\"Duplicate header name {header.name!r}: two columns \"\n                        \"produce a header with the same name. Alias one of \"\n                        \"them to a different name (e.g. via `table.select(...)`) \"\n                        \"to keep both as separate Kafka headers.\"\n                    )\n                header_fields[header.name] = cls.add_column_reference_to_extract(\n                    header, columns_to_extract, extracted_field_indices\n                )\n\n        # Format-dependent parts: handle json and dsv separately\n        if format == \"json\" or format == \"dsv\":\n            if value is not None:\n                raise ValueError(\n                    f\"'value' and format='{format}' cannot be set at the same time\"\n                )\n            if format == \"json\":\n                reserved = {\"time\", \"diff\"}\n                conflicting = reserved.intersection(table._columns.keys())\n                if conflicting:\n                    raise ValueError(\n                        f\"The table has columns {sorted(conflicting)} which \"\n                        f\"clash with the reserved JSON fields written by the \"\n                        f\"connector ('time', 'diff'). Rename or drop the \"\n                        f\"conflicting column(s) before writing in 'json' \"\n                        f\"format, otherwise the output JSON would contain \"\n                        f\"duplicate keys.\"\n                    )\n            for column_name in table._columns:\n                cls.add_column_reference_to_extract(\n                    table[column_name], columns_to_extract, extracted_field_indices\n                )","sourceCodeStart":520,"sourceCodeEnd":556,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/io/_utils.py#L520-L556","documentation":"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.","triggerScenarios":"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.","commonSituations":"Gradually migrating a raw-payload writer to structured json output and leaving the old value= behind; copy-paste between sink configurations.","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=."],"exampleFix":"# before\npw.io.kafka.write(t, ..., format='json', value=pw.this.payload)\n\n# after\nt = t.select(pw.this.payload)  # if only that column is wanted\npw.io.kafka.write(t, ..., format='json')","handlingStrategy":"validation","validationCode":"if format in ('json', 'dsv'):\n    assert value is None, \"'value' cannot be combined with json/dsv output formats\"","typeGuard":null,"tryCatchPattern":"try:\n    pw.io.kafka.write(t, ..., format=format, value=value)\nexcept ValueError as e:\n    if \"cannot be set at the same time\" in str(e):\n        pw.io.kafka.write(t, ..., format=format)\n    else:\n        raise","preventionTips":["Split sink config builders by format family (structured vs raw).","When migrating raw -> json, audit every raw-only argument (value, and note key handling)."],"tags":["pathway","kafka","format","value-column","validation"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}