wavetermdev/waveterm · error

missing filename parameter

Error message

missing filename parameter

What it means

read_text_file requires a "filename" parameter identifying the file to read. If the input object unmarshals fine but leaves Filename empty, parsing stops with this error because there is nothing to open.

Solutions

  1. Include a non-empty "filename" key in the input object.
  2. Rename "path"/"file" keys to "filename" for this tool.
  3. Validate that the intended path string is non-empty before issuing the call.

Example fix

// before
{"input": {"path": "/tmp/a.txt"}}
// after
{"input": {"filename": "/tmp/a.txt"}}
Defensive patterns

Strategy: validation

Validate before calling

if params["filename"] == "" || params["filename"] == nil {
    return errors.New("filename required")
}

Type guard

func hasFilename(m map[string]any) bool {
    s, ok := m["filename"].(string)
    return ok && s != ""
}

Try / catch

params, err := parseReadTextFileInput(input)
if err != nil && err.Error() == "missing filename parameter" {
    // retry with {filename: intendedPath}
}

Prevention

When it happens

Trigger: Calling read_text_file with an input object that omits "filename" or passes it as an empty string.

Common situations: Model-generated tool calls with typo'd keys ("file", "path"); agents confusing parameter names with the read_directory tool's "path"; empty variables interpolated into the call.

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


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/4bbeecf95d1e7b46. Report an issue: GitHub.

Appendix: source

Thrown at pkg/aiusechat/tools_readfile.go:44

	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)
	}

	if result.Offset == nil {
		offset := 0
		result.Offset = &offset
	}

	if *result.Offset < 0 {
		return nil, fmt.Errorf("offset must be non-negative, got %d", *result.Offset)

View on GitHub (pinned to a4447c1563)