{"record":{"id":"bea4a7a77cc90d59","repo":"cloudflare/cloudflared","slug":"datagram-icmp-payload-is-missing","errorCode":null,"errorMessage":"datagram icmp payload is missing","messagePattern":"datagram icmp payload is missing","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quic/v3/datagram_errors.go","lineNumber":19,"sourceCode":"package v3\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n)\n\nvar (\n\tErrInvalidDatagramType                 error = errors.New(\"invalid datagram type expected\")\n\tErrDatagramHeaderTooSmall              error = fmt.Errorf(\"datagram should have at least %d byte\", datagramTypeLen)\n\tErrDatagramPayloadTooLarge             error = errors.New(\"payload length is too large to be bundled in datagram\")\n\tErrDatagramPayloadHeaderTooSmall       error = errors.New(\"payload length is too small to fit the datagram header\")\n\tErrDatagramPayloadInvalidSize          error = errors.New(\"datagram provided is an invalid size\")\n\tErrDatagramResponseMsgInvalidSize      error = errors.New(\"datagram response message is an invalid size\")\n\tErrDatagramResponseInvalidSize         error = errors.New(\"datagram response is an invalid size\")\n\tErrDatagramResponseMsgTooLargeMaximum  error = fmt.Errorf(\"datagram response error message length exceeds the length of the datagram maximum: %d\", maxResponseErrorMessageLen)\n\tErrDatagramResponseMsgTooLargeDatagram error = fmt.Errorf(\"datagram response error message length exceeds the length of the provided datagram\")\n\tErrDatagramICMPPayloadTooLarge         error = fmt.Errorf(\"datagram icmp payload exceeds %d bytes\", maxICMPPayloadLen)\n\tErrDatagramICMPPayloadMissing          error = errors.New(\"datagram icmp payload is missing\")\n)\n\nfunc wrapMarshalErr(err error) error {\n\treturn fmt.Errorf(\"datagram marshal error: %w\", err)\n}\n\nfunc wrapUnmarshalErr(err error) error {\n\treturn fmt.Errorf(\"datagram unmarshal error: %w\", err)\n}\n","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/quic/v3/datagram_errors.go#L1-L29","documentation":"ErrDatagramICMPPayloadMissing is returned when marshaling or unmarshaling an ICMP datagram that carries no ICMP payload. ICMP datagrams consist of a 1-byte ICMPType header plus a mandatory payload; the library refuses to encode or decode an empty one because such a datagram carries no diagnosable information. Wrapped as a marshal/unmarshal error.","triggerScenarios":"MarshalBinary on ICMPDatagram with len(d.Payload)==0; UnmarshalBinary on data where only the 1-byte type header is present (len(data[1:])==0).","commonSituations":"Constructing ICMP error/response datagrams without attaching the original packet bytes or ICMP body; a peer sending a bare type byte; stripping the payload when copying datagrams.","solutions":["Always populate the ICMP payload (original packet or message body) before constructing ICMPDatagram","Validate len(payload) > 0 before calling MarshalBinary/UnmarshalBinary and drop empty ICMP datagrams earlier","Check errors.Is(err, v3.ErrDatagramICMPPayloadMissing) and log the dropped datagram rather than failing the session"],"exampleFix":"// before\nd := &v3.ICMPDatagram{Payload: []byte{}}\n_, err := d.MarshalBinary() // -> ErrDatagramICMPPayloadMissing\n// after\nif len(rawICMPBody) == 0 {\n    return // nothing diagnosable to forward\n}\nd := &v3.ICMPDatagram{Payload: rawICMPBody}\n_, err := d.MarshalBinary()","handlingStrategy":"validation","validationCode":"if len(icmpBody) == 0 {\n    return // skip constructing ICMP datagram\n}","typeGuard":null,"tryCatchPattern":"if _, err := d.MarshalBinary(); errors.Is(err, v3.ErrDatagramICMPPayloadMissing) {\n    logger.Debug().Msg(\"ICMP datagram without payload dropped\")\n    return\n}","preventionTips":["Never build ICMP datagrams without the body/original packet bytes","Drop empty ICMP datagrams at the receive path","Validate payload before both marshal and unmarshal"],"tags":["quic","datagram","icmp","missing-payload"],"backgroundTag":"empty-required-field","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}