{"record":{"id":"1021092985211dba","repo":"kovidgoyal/kitty","slug":"failed-to-load-output-from-custom-processor-v-wi","errorCode":null,"errorMessage":"Failed to load output from custom processor %#v with error: %w","messagePattern":"Failed to load output from custom processor %#v with error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kittens/hints/marks.go","lineNumber":687,"sourceCode":"\t\tstdout, stderr := bytes.Buffer{}, bytes.Buffer{}\n\t\tcmd.Stdout, cmd.Stderr = &stdout, &stderr\n\t\terr = cmd.Run()\n\t\tif err != nil {\n\t\t\tvar e *exec.ExitError\n\t\t\tif errors.As(err, &e) && e.ExitCode() == 2 {\n\t\t\t\terr = run_basic_matching()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tgoto process_answer\n\t\t\t} else {\n\t\t\t\treturn \"\", nil, nil, fmt.Errorf(\"Failed to run custom processor %#v with error: %w\\n%s\", opts.CustomizeProcessing, err, stderr.String())\n\t\t\t}\n\t\t}\n\t\tans = make([]Mark, 0, 32)\n\t\terr = json.Unmarshal(stdout.Bytes(), &ans)\n\t\tif err != nil {\n\t\t\treturn \"\", nil, nil, fmt.Errorf(\"Failed to load output from custom processor %#v with error: %w\", opts.CustomizeProcessing, err)\n\t\t}\n\t\terr = adjust_python_offsets(sanitized_text, ans)\n\t\tif err != nil {\n\t\t\treturn \"\", nil, nil, fmt.Errorf(\"Custom processor %#v produced invalid mark output with error: %w\", opts.CustomizeProcessing, err)\n\t\t}\n\t} else if opts.Type == \"hyperlink\" {\n\t\tans = hyperlinks\n\t} else if opts.Type == \"word\" {\n\t\tans = mark_words(sanitized_text, opts)\n\t} else {\n\t\terr = run_basic_matching()\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\nprocess_answer:\n\tif len(ans) == 0 {\n\t\treturn \"\", nil, nil, &ErrNoMatches{Type: opts.Type, Pattern: used_pattern}","sourceCodeStart":669,"sourceCodeEnd":705,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/hints/marks.go#L669-L705","documentation":"The CustomizeProcessing custom processor ran successfully but its stdout was not valid JSON deserializable into []Mark. json.Unmarshal failed, meaning output was empty, truncated, or not a JSON array of mark objects.","triggerScenarios":"Custom processor printing logs/diagnostics to stdout instead of stderr, emitting a JSON object instead of an array, or producing no output at all.","commonSituations":"Debug print statements left in the processor that pollute stdout; processor returning an object {'marks': []}; older processor output format.","solutions":["Send all logging to stderr and only the marks JSON array to stdout","Validate output with: my_processor.py < input.json | jq 'type' — must be 'array'","Match the Mark schema: array of objects with start/end index fields"],"exampleFix":"# before\nprint('processing...')  # stdout pollution\nprint(json.dumps(marks))\n# after\nprint('processing...', file=sys.stderr)\nprint(json.dumps(marks))","handlingStrategy":"validation","validationCode":"out, err := runProcessor(input)\nif err == nil {\n    if !json.Valid(out) { err = errors.New(\"processor stdout not JSON\") }\n}","typeGuard":null,"tryCatchPattern":"On 'Failed to load output from custom processor', dump raw stdout for inspection and fall back to built-in hints.","preventionTips":["Route processor logs to stderr only","Verify output shape is a JSON array with jq in CI"],"tags":["kitty","hints","json","custom-processor"],"backgroundTag":"invalid-json-output","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}