{"record":{"id":"8bdfab29f23571e6","repo":"wavetermdev/waveterm","slug":"missing-contents-parameter","errorCode":null,"errorMessage":"missing contents parameter","messagePattern":"missing contents parameter","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/aiusechat/tools_builder.go","lineNumber":71,"sourceCode":"\t\t\"build_success\": result.Success,\n\t\t\"build_error\":   result.ErrorMessage,\n\t\t\"build_output\":  result.BuildOutput,\n\t}\n}\n\nfunc parseBuilderWriteAppFileInput(input any) (*builderWriteAppFileParams, error) {\n\tresult := &builderWriteAppFileParams{}\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.Contents == \"\" {\n\t\treturn nil, fmt.Errorf(\"missing contents parameter\")\n\t}\n\n\treturn result, nil\n}\n\nfunc GetBuilderWriteAppFileToolDefinition(appId string, builderId string) uctypes.ToolDefinition {\n\treturn uctypes.ToolDefinition{\n\t\tName:        \"builder_write_app_file\",\n\t\tDisplayName: \"Write App File\",\n\t\tDescription: fmt.Sprintf(\"Write the app.go file for app %s\", appId),\n\t\tToolLogName: \"builder:write_app\",\n\t\tStrict:      false,\n\t\tInputSchema: map[string]any{\n\t\t\t\"type\": \"object\",\n\t\t\t\"properties\": map[string]any{\n\t\t\t\t\"contents\": map[string]any{\n\t\t\t\t\t\"type\":        \"string\",\n\t\t\t\t\t\"description\": \"The contents to write to app.go\",","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/aiusechat/tools_builder.go#L53-L89","documentation":"Input unmarshaled fine but the required Contents field is the empty string. The write-app-file tool refuses to write an empty file body, treating it as a missing parameter. Because Contents is a string, omitted and \"\" are indistinguishable here — both trigger this error.","triggerScenarios":"Tool called with {} or {\"contents\": \"\"} — the contents key absent or explicitly empty after unmarshal.","commonSituations":"Model generating an empty file body (e.g. it intended to only create the file); prompt asking to 'clear' a file where a delete/edit op was appropriate; truncation cutting off long contents.","solutions":["Provide non-empty contents: {\"contents\": \"<file text>\"}","If the intent is an empty/blank file, pass at least a placeholder (e.g. \"\\n\") or use a delete operation instead","Strengthen the tool description to state contents must be non-empty"],"exampleFix":"// before\n{\"file\": \"app.tsx\", \"contents\": \"\"}\n// after\n{\"file\": \"app.tsx\", \"contents\": \"export default function App() { return null }\"}","handlingStrategy":"validation","validationCode":"if m, ok := input.(map[string]any); ok { if c, _ := m[\"contents\"].(string); c == \"\" { return errors.New(\"contents must be a non-empty string\") } }","typeGuard":"func hasContents(input any) bool { m, ok := input.(map[string]any); if !ok { return false }; s, ok := m[\"contents\"].(string); return ok && s != \"\" }","tryCatchPattern":"params, err := parseBuilderWriteAppFileInput(input); if err != nil && strings.Contains(err.Error(), \"missing contents\") { return fmt.Errorf(\"refusing to write empty file: %w\", err) }","preventionTips":["Always include non-empty contents in write-app-file calls","Use a delete/edit tool instead of writing empty content to clear a file","Guard long contents against truncation before sending"],"tags":["tool-input","missing-parameter","builder-tools"],"backgroundTag":"missing-required-argument","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}