{"record":{"id":"8839e4764563c0ef","repo":"wavetermdev/waveterm","slug":"input-is-required-8839e4","errorCode":null,"errorMessage":"input is required","messagePattern":"input is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/aiusechat/tools_readfile.go","lineNumber":36,"sourceCode":")\n\nconst ReadFileDefaultLineCount = 100\nconst ReadFileDefaultMaxBytes = 50 * 1024\nconst StopReasonMaxBytes = \"max_bytes\"\n\ntype readTextFileParams struct {\n\tFilename string  `json:\"filename\"`\n\tOrigin   *string `json:\"origin\"` // \"start\" or \"end\", defaults to \"start\"\n\tOffset   *int    `json:\"offset\"` // lines to skip, defaults to 0\n\tCount    *int    `json:\"count\"`  // number of lines to read, defaults to DefaultLineCount\n\tMaxBytes *int    `json:\"max_bytes\"`\n}\n\nfunc parseReadTextFileInput(input any) (*readTextFileParams, error) {\n\tresult := &readTextFileParams{}\n\n\tif input == nil {\n\t\treturn nil, fmt.Errorf(\"input is required\")\n\t}\n\n\tif err := utilfn.ReUnmarshal(result, input); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid input format: %w\", err)\n\t}\n\n\tif result.Filename == \"\" {\n\t\treturn nil, fmt.Errorf(\"missing filename parameter\")\n\t}\n\n\tif result.Origin == nil {\n\t\torigin := \"start\"\n\t\tresult.Origin = &origin\n\t}\n\n\tif *result.Origin != \"start\" && *result.Origin != \"end\" {\n\t\treturn nil, fmt.Errorf(\"invalid origin value '%s': must be 'start' or 'end'\", *result.Origin)\n\t}","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/aiusechat/tools_readfile.go#L18-L54","documentation":"parseReadTextFileInput rejects a nil input before attempting to unmarshal the read_text_file parameters. The tool's input argument must be a JSON-like object; nothing to read means no filename can be extracted, so it fails fast with this error.","triggerScenarios":"Invoking read_text_file with input=null / omitted argument, or the MCP tool-call layer delivering an empty params map.","commonSituations":"Hand-written tool-call JSON missing the \"input\" wrapper; agent frameworks dropping empty object arguments; tests calling the callback with nil.","solutions":["Provide a non-null input object: {\"filename\": \"/path/to/file\"}.","If building tool calls programmatically, serialize parameters instead of passing nil.","Wrap the tool call in validation that asserts input is an object before sending."],"exampleFix":"// before\nreadTextFileCallback(nil)\n// after\nreadTextFileCallback(map[string]any{\"filename\": \"/tmp/log.txt\"})","handlingStrategy":"type-guard","validationCode":"if input == nil || len(input.(map[string]any)) == 0 { return errors.New(\"input object required\") }","typeGuard":"func isNonEmptyObject(v any) bool {\n    m, ok := v.(map[string]any)\n    return ok && len(m) > 0\n}","tryCatchPattern":"params, err := parseReadTextFileInput(input)\nif err != nil && err.Error() == \"input is required\" {\n    // return usage help: requires {filename: string}\n}","preventionTips":["Never omit the input argument in tool-call JSON","Assert input is a non-null object before dispatching","Include at minimum {\"filename\": \"...\"} in every call"],"tags":["input-validation","tooling","json"],"backgroundTag":"missing-required-argument","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}