{"record":{"id":"8bd9ca598c52793a","repo":"JuliusBrussee/caveman","slug":"cachebench-verifier-returned-duplicate-or-invalid","errorCode":null,"errorMessage":"cachebench: verifier returned duplicate or invalid JSON","messagePattern":"cachebench: verifier returned duplicate or invalid JSON","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/replay.go","lineNumber":52,"sourceCode":"\tOriginalRequest  json.RawMessage `json:\"original_request\"`\n\tOptimizedRequest json.RawMessage `json:\"optimized_request\"`\n\tProviderResponse json.RawMessage `json:\"provider_response\"`\n}\n\n// VerificationCommandOutput is strict external task-grader response.\ntype VerificationCommandOutput struct {\n\tSchema    string          `json:\"schema\"`\n\tRequestID string          `json:\"request_id\"`\n\tPassed    bool            `json:\"passed\"`\n\tVerifier  string          `json:\"verifier\"`\n\tEvidence  json.RawMessage `json:\"evidence\"`\n}\n\n// ParseVerificationCommandOutput validates and binds external grader evidence.\nfunc ParseVerificationCommandOutput(raw []byte, requestID string) (TaskVerification, error) {\n\traw = bytes.TrimSpace(raw)\n\tif !validUniqueJSONObject(raw) {\n\t\treturn TaskVerification{}, errors.New(\"cachebench: verifier returned duplicate or invalid JSON\")\n\t}\n\tdecoder := json.NewDecoder(bytes.NewReader(raw))\n\tdecoder.DisallowUnknownFields()\n\tvar result VerificationCommandOutput\n\tif decoder.Decode(&result) != nil {\n\t\treturn TaskVerification{}, errors.New(\"cachebench: verifier returned invalid JSON\")\n\t}\n\tvar trailing any\n\tif decoder.Decode(&trailing) != io.EOF || result.Schema != VerificationSchema || result.RequestID != requestID || !validBoundedText(result.Verifier, 256, false) || len(result.Evidence) == 0 || !json.Valid(result.Evidence) || bytes.Equal(bytes.TrimSpace(result.Evidence), []byte(\"null\")) {\n\t\treturn TaskVerification{}, errors.New(\"cachebench: verifier returned incomplete or mismatched evidence\")\n\t}\n\treturn TaskVerification{Passed: result.Passed, Verifier: result.Verifier, Evidence: append([]byte(nil), raw...)}, nil\n}\n\n// ReplayLimits bounds paid population, schedule, and concurrency.\ntype ReplayLimits struct {\n\tMaxRequests             int\n\tMaxDeclaredBilledTokens int64","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/replay.go#L34-L70","documentation":"Raised in ParseVerificationCommandOutput: the external verifier command's stdout bytes failed validUniqueJSONObject. The grader's output must be a single JSON object; duplicate keys or any non-object/invalid JSON in the verifier payload is rejected before decoding.","triggerScenarios":"Thrown at cacheengine/cachebench/replay.go:52 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the verifier script to emit exactly one JSON object with unique keys","Capture the verifier's raw stdout to inspect what it actually printed (stderr, log lines, multiple documents)","Ensure no wrapper or shell prepends text to the JSON payload"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}