{"record":{"id":"a0e9a650f6b03ee5","repo":"dagger/dagger","slug":"decode-field-of-length-d-only-d-bytes-remain","errorCode":null,"errorMessage":"decode field of length %d: only %d bytes remain","messagePattern":"decode field of length (.+?): only (.+?) bytes remain","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/clientdb/store_codec.go","lineNumber":110,"sourceCode":"\nfunc (d *rowDecoder) length() (int, error) {\n\tv, n := binary.Uvarint(d.buf[d.off:])\n\tif n == 0 {\n\t\treturn 0, fmt.Errorf(\"decode length: truncated varint\")\n\t}\n\tif n < 0 {\n\t\treturn 0, fmt.Errorf(\"decode length: varint overflow\")\n\t}\n\td.off += n\n\tif v > uint64(maxInt) {\n\t\treturn 0, fmt.Errorf(\"decode length: %d overflows int\", v)\n\t}\n\treturn int(v), nil\n}\n\nfunc (d *rowDecoder) take(n int) ([]byte, error) {\n\tif n < 0 || n > len(d.buf)-d.off {\n\t\treturn nil, fmt.Errorf(\"decode field of length %d: only %d bytes remain\", n, len(d.buf)-d.off)\n\t}\n\tv := d.buf[d.off : d.off+n]\n\td.off += n\n\treturn v, nil\n}\n\nfunc (d *rowDecoder) string() (string, error) {\n\tn, err := d.length()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tv, err := d.take(n)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn string(v), nil\n}\n","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/engine/clientdb/store_codec.go#L92-L128","documentation":"Returned by rowDecoder.take when a decoded field length exceeds the bytes remaining in the buffer. The row data is truncated or corrupt: a varint length prefix claims more bytes than the buffer holds, indicating a torn write or version-mismatched encoding in the client DB store.","triggerScenarios":"Thrown at engine/clientdb/store_codec.go:110 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Handle the error by discarding/rebuilding the corrupt DB row","Verify encoder and decoder agree on the row format version","Add checksums to detect torn writes at ingestion"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}