pathwaycom/pathway · error · ValueError

Unknown payload format: {req_format}

Error message

Unknown payload format: {req_format}

What it means

Raised by the internal HTTP connector payload formatter (_format_output_payload) when req_format is neither "json" nor "custom". It only knows how to serialize a row as JSON (adding time/diff metadata) or to call a user-supplied custom formatter; any other format string is a programming/internal error.

Source

Thrown at python/pathway/io/http/_common.py:146

        message = message.replace(wildcard_to_replace, str(v))
    return message


def prepare_request_payload(
    row: dict[str, Any],
    time: int,
    is_addition: bool,
    req_format: str,
    text: str | None,
):
    if req_format == "json":
        row["time"] = time
        row["diff"] = 1 if is_addition else -1
        return json.dumps(row)
    elif req_format == "custom":
        return unescape(text or "", row, time, is_addition)
    else:
        raise ValueError(f"Unknown payload format: {req_format}")

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Use format="json" for JSON payloads or format="custom" with a custom_payload_function when using the public pw.io.http REST connector.
  2. If you call the internal helper directly, validate req_format in {"json", "custom"} before invoking it and map unsupported names to a user-facing error.
  3. Update forked/copied connector code to the current pathway version's format names.

Example fix

# before
_format_output_payload(row, t, diff, "xml", None)

# after
if fmt not in ("json", "custom"):
    raise ValueError(f"unsupported format {fmt!r} for HTTP output")
_format_output_payload(row, t, diff, fmt, None)
Defensive patterns

Strategy: type-guard

Validate before calling

if req_format not in ("json", "custom"):
    raise ValueError(f"unsupported payload format {req_format!r}; use 'json' or 'custom'")

Type guard

def is_known_payload_format(fmt: str) -> bool:
    return fmt in ("json", "custom")

Prevention

When it happens

Trigger: An HTTP output endpoint configured with format="xml" or "text" reaching the payload serialization step; internal API wrappers passing an unchecked format string through to _format_output_payload.

Common situations: Third-party code or forks calling pathway's internal _common helpers with new format names; stale format constants after a pathway upgrade renamed formats; a custom REST connector wrapper that forwards a user-supplied format without validation.

Related errors


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