{"record":{"id":"4bbeecf95d1e7b46","repo":"wavetermdev/waveterm","slug":"missing-filename-parameter","errorCode":null,"errorMessage":"missing filename parameter","messagePattern":"missing filename parameter","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/aiusechat/tools_readfile.go","lineNumber":44,"sourceCode":"\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}\n\n\tif result.Offset == nil {\n\t\toffset := 0\n\t\tresult.Offset = &offset\n\t}\n\n\tif *result.Offset < 0 {\n\t\treturn nil, fmt.Errorf(\"offset must be non-negative, got %d\", *result.Offset)","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/aiusechat/tools_readfile.go#L26-L62","documentation":"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.","triggerScenarios":"Calling read_text_file with an input object that omits \"filename\" or passes it as an empty string.","commonSituations":"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.","solutions":["Include a non-empty \"filename\" key in the input object.","Rename \"path\"/\"file\" keys to \"filename\" for this tool.","Validate that the intended path string is non-empty before issuing the call."],"exampleFix":"// before\n{\"input\": {\"path\": \"/tmp/a.txt\"}}\n// after\n{\"input\": {\"filename\": \"/tmp/a.txt\"}}","handlingStrategy":"validation","validationCode":"if params[\"filename\"] == \"\" || params[\"filename\"] == nil {\n    return errors.New(\"filename required\")\n}","typeGuard":"func hasFilename(m map[string]any) bool {\n    s, ok := m[\"filename\"].(string)\n    return ok && s != \"\"\n}","tryCatchPattern":"params, err := parseReadTextFileInput(input)\nif err != nil && err.Error() == \"missing filename parameter\" {\n    // retry with {filename: intendedPath}\n}","preventionTips":["Use the exact key \"filename\" (not path/file/target)","Verify the path variable is non-empty before interpolation","Template-review model tool-call prompts for key names"],"tags":["input-validation","missing-parameter","tooling"],"backgroundTag":"missing-required-argument","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}