pub fn detectable_error_id(raw: &[u8], error: &RpcError) -> Option<Value>Expand description
Recover the request id for an error response, per JSON-RPC 2.0 §5:
the response id MUST echo the request’s when it is detectable, and
be null only “if there was an error in detecting the id” (parse
error / invalid request). RpcError::NotToolCall and
RpcError::BadParams both mean the envelope parsed as a
well-formed JSON-RPC 2.0 object, so the id IS detectable — replying
null broke client correlation (a pending initialize call hung
until timeout because its error response carried id: null).
Parse-class failures (invalid JSON, duplicate keys, oversize,
non-2.0 envelope) keep null: the id is absent, ambiguous, or
untrustworthy there.