wavetermdev/waveterm · error
input is required
Error message
input is required
What it means
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.
Source
Thrown at pkg/aiusechat/tools_readfile.go:36
)
const ReadFileDefaultLineCount = 100
const ReadFileDefaultMaxBytes = 50 * 1024
const StopReasonMaxBytes = "max_bytes"
type readTextFileParams struct {
Filename string `json:"filename"`
Origin *string `json:"origin"` // "start" or "end", defaults to "start"
Offset *int `json:"offset"` // lines to skip, defaults to 0
Count *int `json:"count"` // number of lines to read, defaults to DefaultLineCount
MaxBytes *int `json:"max_bytes"`
}
func parseReadTextFileInput(input any) (*readTextFileParams, error) {
result := &readTextFileParams{}
if input == nil {
return nil, fmt.Errorf("input is required")
}
if err := utilfn.ReUnmarshal(result, input); err != nil {
return nil, fmt.Errorf("invalid input format: %w", err)
}
if result.Filename == "" {
return nil, fmt.Errorf("missing filename parameter")
}
if result.Origin == nil {
origin := "start"
result.Origin = &origin
}
if *result.Origin != "start" && *result.Origin != "end" {
return nil, fmt.Errorf("invalid origin value '%s': must be 'start' or 'end'", *result.Origin)
}View on GitHub (pinned to a4447c1563)
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.
Example fix
// before
readTextFileCallback(nil)
// after
readTextFileCallback(map[string]any{"filename": "/tmp/log.txt"}) Defensive patterns
Strategy: type-guard
Validate before calling
if input == nil || len(input.(map[string]any)) == 0 { return errors.New("input object required") } Type guard
func isNonEmptyObject(v any) bool {
m, ok := v.(map[string]any)
return ok && len(m) > 0
} Try / catch
params, err := parseReadTextFileInput(input)
if err != nil && err.Error() == "input is required" {
// return usage help: requires {filename: string}
} Prevention
- 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
When it happens
Trigger: Invoking read_text_file with input=null / omitted argument, or the MCP tool-call layer delivering an empty params map.
Common situations: Hand-written tool-call JSON missing the "input" wrapper; agent frameworks dropping empty object arguments; tests calling the callback with nil.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- invalid input format: %w
- missing filename parameter
- invalid origin value '%s': must be 'start' or 'end'
- offset must be non-negative, got %d
- count must be at least 1, got %d
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/8839e4764563c0ef.
Report an issue: GitHub.