{"record":{"id":"3df6dc2f7a27b68c","repo":"JuliusBrussee/caveman","slug":"proposalrun-detail-contains-trailing-json","errorCode":null,"errorMessage":"proposalrun: detail contains trailing JSON","messagePattern":"proposalrun: detail contains trailing JSON","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/proposalrun/proposalrun.go","lineNumber":69,"sourceCode":"// hash identically, while adjacent arbitrary-precision integers remain\n// distinct. The bounds mirror PostgreSQL's numeric-backed jsonb limits and\n// reject values that could not be persisted there before allocating output.\n// The decoder enforces the JSON number grammar (including rejecting NaN/Inf),\n// and a second decode below rejects any trailing value or non-whitespace data.\nfunc CanonicalDetail(detail json.RawMessage) ([]byte, error) {\n\tif len(detail) == 0 {\n\t\treturn []byte(\"{}\"), nil\n\t}\n\tvar v any\n\tdec := json.NewDecoder(bytes.NewReader(detail))\n\tdec.UseNumber()\n\tif err := dec.Decode(&v); err != nil {\n\t\treturn nil, fmt.Errorf(\"proposalrun: detail is not valid JSON: %w\", err)\n\t}\n\tvar trailing any\n\tif err := dec.Decode(&trailing); err != io.EOF {\n\t\tif err == nil {\n\t\t\treturn nil, fmt.Errorf(\"proposalrun: detail contains trailing JSON\")\n\t\t}\n\t\treturn nil, fmt.Errorf(\"proposalrun: detail contains trailing data: %w\", err)\n\t}\n\tv, err := canonicalizeJSONValue(v)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"proposalrun: canonicalize detail: %w\", err)\n\t}\n\tout, err := json.Marshal(v)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"proposalrun: marshal canonical detail: %w\", err)\n\t}\n\treturn out, nil\n}\n\n// PostgreSQL jsonb stores JSON numbers using its numeric type. These are the\n// documented numeric bounds (131072 digits before and 16383 after the decimal\n// point); rejecting at the canonicalization boundary keeps write and read-back\n// hashing deterministic and avoids unbounded strings from hostile exponents.","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/shared/platform/proposalrun/proposalrun.go#L51-L87","documentation":"Error \"proposalrun: detail contains trailing JSON\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at shared/platform/proposalrun/proposalrun.go:69 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove trailing JSON from the detail payload."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}