You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(protocols): makers reject bad arguments with the reader's 'invalid format' text #2296
Describe the bug
Several _make_* builders reject a caller-supplied argument with the parse-error text <alias>: [Chunk|Param|Cause|OptNo N] invalid format. That text says the wire data is malformed. Here nothing was parsed, so the caller gets no hint which keyword was wrong or what value was passed.
Reproduction (main9d504ead5)
>>> SCTP.__new__(SCTP)._make_chunk_data(Chunk(0), flags=b'\x00\x00')
ProtocolError: SCTP: [Chunk 0] invalid format
>>> SCTP.__new__(SCTP)._make_param_hostname(Parameter.Host_Name_Address, name=b'example')
ProtocolError: SCTP: [Param 11] invalid format
Expected behavior SCTP: [Chunk 0] invalid flags: must be one octet, not b'\x00\x00' and SCTP: [Param 11] invalid name: must be NUL-terminated, not b'example'. One convention covers all of these sites: the maker names the argument and shows its value.
SCTP: the _make_chunk_* flags guards, _make_param_hostname, _make_cause_invalid_stream
MH: make, _make_opt_bad, _make_opt_badf, _make_opt_auth, and the _make_opt_pad warning
TCP _make_mptcp_capable, HIP _make_locator, PCAP-NG _make_block_dsb
Readers keep the invalid format text, so the SCTP: [Chunk 0] invalid format pin in test_transport_edge_roundtrip_unit (a parse case) stays. No test pins a maker's text.
System information
Linux, CPython 3.14.9, checkout main9d504ead5.
Related: #2276 and #2273 change _make_locator and _make_block_dsb for other reasons; land whichever is first and rebase the other.
Blocked until the round-7 fix PRs for #2268–#2316 merge. This change spans the makers in most protocol modules, which those fixes edit, so it starts from the merged tree.
Picking this up as suggested — see PR #2404, which aligns all maker-side guards with the invalid <argument>: <requirement>, not <value!r> convention (reader-side messages untouched) and adds 12 full-string message tests.
Activity
JarryShaw commentedon Oct 26, 2026
Blocked until the round-7 fix PRs for #2268–#2316 merge. This change spans the makers in most protocol modules, which those fixes edit, so it starts from the merged tree.
JarryShaw commentedon Oct 27, 2026
Unblocking — the round-7 fix PRs for #2268–#2316 have all landed now (this is the last one still open in that range). Open to pick up.
Qiu-LingYan commentedon Oct 28, 2026
Picking this up as suggested — see PR #2404, which aligns all maker-side guards with the
invalid <argument>: <requirement>, not <value!r>convention (reader-side messages untouched) and adds 12 full-string message tests.fix(protocols): makers name the rejected argument and value in error …
fix(protocols): makers name the rejected argument and value in error …
fix(protocols): four more maker guards name the rejected argument
docs(protocols,foundation,tests): state current behaviour in maker, r…
docs(protocols,foundation,tests): state current behaviour in maker, r…
docs(protocols,foundation,tests): state current behaviour in maker, r…
docs(protocols,foundation,tests): state current behaviour in maker, r…
docs: #719-style prose sweep after the #1090-1102 defect wave (#2408)