{"record":{"id":"710a89dca91c5e33","repo":"JuliusBrussee/caveman","slug":"not-losslessly-toon-encodable-invalid-json-or-ne-710a89","errorCode":null,"errorMessage":"not losslessly TOON-encodable (invalid JSON, or nested/non-uniform shape); keep JSON","messagePattern":"not losslessly TOON-encodable \\(invalid JSON, or nested/non-uniform shape\\); keep JSON","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/toon.go","lineNumber":15,"sourceCode":"package engine\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\n\t\"github.com/JuliusBrussee/caveman/engine/compressors\"\n)\n\n// EncodeTOON converts JSON to the lossless TOON subset without CCR or size\n// gating. It is for explicit agent/CLI requests, not automatic proxy routing.\nfunc (e *Engine) EncodeTOON(input []byte) ([]byte, error) {\n\tout, ok := compressors.NewTOON().Compress(input)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"not losslessly TOON-encodable (invalid JSON, or nested/non-uniform shape); keep JSON\")\n\t}\n\treturn out, nil\n}\n\n// DecodeTOON converts TOON back to compact JSON. Malformed TOON fails closed.\nfunc (e *Engine) DecodeTOON(input []byte) ([]byte, error) {\n\tv, ok := compressors.DecodeTOON(input)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"not valid TOON\")\n\t}\n\tout, err := json.Marshal(v)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn out, nil\n}\n","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/engine/toon.go#L1-L32","documentation":"Error \"not losslessly TOON-encodable (invalid JSON, or nested/non-uniform shape); keep JSON\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at engine/toon.go:15 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Keep the payload as JSON; it is not losslessly TOON-encodable."],"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"}