{"record":{"id":"4008a9590240b9a6","repo":"JuliusBrussee/caveman","slug":"cache-replay-could-not-encode-verifier-input","errorCode":null,"errorMessage":"cache-replay: could not encode verifier input","messagePattern":"cache-replay: could not encode verifier input","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cmd/cache-replay/main.go","lineNumber":125,"sourceCode":"\tgo func() {\n\t\terr := json.NewEncoder(inputWriter).Encode(verificationInput)\n\t\t_ = inputWriter.CloseWithError(err)\n\t\tencodeDone <- err\n\t}()\n\tcommand.Stdin = inputReader\n\tcommand.Env = append([]string(nil), verifier.environment...)\n\tstdout := &boundedBuffer{max: verifier.maxOutputBytes}\n\tstderr := &boundedBuffer{max: 64 << 10}\n\tcommand.Stdout = stdout\n\tcommand.Stderr = stderr\n\trunErr := command.Run()\n\t_ = inputReader.Close()\n\tencodeErr := <-encodeDone\n\tif runErr != nil {\n\t\treturn cachebench.TaskVerification{}, errors.New(\"cache-replay: verifier process failed\")\n\t}\n\tif encodeErr != nil {\n\t\treturn cachebench.TaskVerification{}, errors.New(\"cache-replay: could not encode verifier input\")\n\t}\n\treturn cachebench.ParseVerificationCommandOutput(stdout.Bytes(), input.Trace.RequestID)\n}\n\ntype boundedBuffer struct {\n\tbuffer bytes.Buffer\n\tmax    int64\n}\n\nfunc (buffer *boundedBuffer) Write(value []byte) (int, error) {\n\tif int64(buffer.buffer.Len())+int64(len(value)) > buffer.max {\n\t\tremaining := buffer.max - int64(buffer.buffer.Len())\n\t\tif remaining > 0 {\n\t\t\twritten, _ := buffer.buffer.Write(value[:remaining])\n\t\t\treturn written, errors.New(\"output limit exceeded\")\n\t\t}\n\t\treturn 0, errors.New(\"output limit exceeded\")\n\t}","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/cacheengine/cmd/cache-replay/main.go#L107-L143","documentation":"Returned by the cache-replay verifier wrapper when the goroutine that JSON-encodes the verifier input fails. The wrapper encodes the input into an io.Pipe feeding the child's stdin; if json.Marshal/Encoder returns an error (for example a channel, function, or cycle in the input value), encodeErr becomes non-nil and is surfaced as this message. Note runErr is checked first, so a child failure masks an encode failure.","triggerScenarios":"The TaskVerificationInput (or nested TraceRecord.Body raw JSON) contains a value json.Encoder cannot serialize, or the inputReader pipe is closed before encoding finishes (which usually coincides with the child exiting early, in which case 723 fires instead).","commonSituations":"Almost always secondary to a verifier that exits immediately and closes stdin (then error 723 wins); a corrupted trace Body that fails raw-message validation; custom code extending the input struct with unmarshalable fields.","solutions":["First resolve error 723 if present — the child failing early closes the pipe and causes the encode error","Re-run with preflight only (omit -execute) to validate the trace before verification is attempted","If you modified the input types, ensure every field is json-encodable (no chans, funcs, cycles)","Confirm the trace passes cachebench.ReadTraceJSONL cleanly, including Body digest checks"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil {\n\tif err.Error() == \"cache-replay: could not encode verifier input\" {\n\t\t// runErr is checked first; if you see this alone, suspect input serialization\n\t\treturn fmt.Errorf(\"verifier input not encodable; validate the trace with a preflight run\")\n\t}\n}","preventionTips":["Always run preflight (no -execute) first so trace/Body problems surface before the verifier stage","Treat 724 appearing together with 723 as a child-exit symptom, not an encoding bug"],"tags":["go","json-encoding","subprocess","verification"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}