{"record":{"id":"11d62302a10e8705","repo":"t8y2/dbx","slug":"reader-cannot-read-token-payload","errorCode":null,"errorMessage":"reader cannot read token payload","messagePattern":"reader cannot read token payload","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/argo-go/config.go","lineNumber":812,"sourceCode":"\t}\n\treturn identifier, password, nil\n}\n\nfunc readHadoopByteArray(reader io.ByteReader) ([]byte, error) {\n\tlength, err := readHadoopVInt(reader)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif length < 0 {\n\t\treturn nil, fmt.Errorf(\"negative length %d\", length)\n\t}\n\tif length > 64*1024*1024 {\n\t\treturn nil, fmt.Errorf(\"length %d exceeds limit\", length)\n\t}\n\tvalue := make([]byte, int(length))\n\tbyteReader, ok := reader.(io.Reader)\n\tif !ok {\n\t\treturn nil, errors.New(\"reader cannot read token payload\")\n\t}\n\tif _, err := io.ReadFull(byteReader, value); err != nil {\n\t\treturn nil, err\n\t}\n\treturn value, nil\n}\n\nfunc readHadoopVInt(reader io.ByteReader) (int64, error) {\n\tfirstByte, err := reader.ReadByte()\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tfirst := int8(firstByte)\n\tif first >= -112 {\n\t\treturn int64(first), nil\n\t}\n\tlength := -111 - int(first)\n\tnegative := false","sourceCodeStart":794,"sourceCodeEnd":830,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/argo-go/config.go#L794-L830","documentation":"While decoding a length-prefixed Hadoop token field, the library has read the field length and needs to io.ReadFull the payload, which requires the reader to also implement io.Reader. The io.ByteReader passed in is expected to be *strings.Reader, so this error only fires if the concrete reader type cannot read raw bytes. For a developer, it is effectively an internal invariant failure in token decoding, not a config problem.","triggerScenarios":"Calling readHadoopByteArray with an io.ByteReader implementation that does not also implement io.Reader. In the shipped code path the reader is always *strings.Reader, so the error is practically unreachable via public API; it can only be hit by tests or custom code reusing readHadoopByteArray with a ByteReader-only wrapper.","commonSituations":"Custom tooling that reuses the driver's internal token-decoding helpers with a bufio.Reader stripped or wrapped type; refactors that change the reader type passed into decodeHadoopDelegationToken.","solutions":["If you hit this via the public API, report it — it indicates an internal regression; the reader should always be *strings.Reader.","If you call readHadoopByteArray directly, pass a reader implementing both io.ByteReader and io.Reader (e.g. strings.Reader, bytes.Reader, bufio.Reader).","Avoid wrapping the reader in a type that only satisfies io.ByteReader before calling the decoder."],"exampleFix":"// before\nvar r io.ByteReader = myByteOnlyReader{buf}\nidentifier, err := readHadoopByteArray(r)\n// after\nreader := strings.NewReader(string(decoded))\nidentifier, err := readHadoopByteArray(reader) // *strings.Reader is both ByteReader and Reader","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func asFullReader(r io.ByteReader) (io.Reader, bool) {\n\trr, ok := r.(io.Reader)\n\treturn rr, ok\n}","tryCatchPattern":"if err := driver.Connect(cfg); err != nil {\n\tif strings.Contains(err.Error(), \"reader cannot read token payload\") {\n\t\t// internal decoder regression: check driver version, upgrade\n\t}\n\treturn err\n}","preventionTips":["Use the public config API instead of calling internal decode helpers with custom readers.","If reusing readHadoopByteArray, always pass strings.Reader/bytes.Reader/bufio.Reader.","Pin driver versions and test token decoding after upgrades."],"tags":["go","io","internal","serialization"],"backgroundTag":"reader-type-not-supported","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}