{"record":{"id":"f07a44136790b7eb","repo":"wavetermdev/waveterm","slug":"input-is-required","errorCode":null,"errorMessage":"input is required","messagePattern":"input is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/aiusechat/tools_builder.go","lineNumber":63,"sourceCode":"\t\treturn map[string]any{\n\t\t\t\"build_success\": false,\n\t\t\t\"build_error\":   err.Error(),\n\t\t\t\"build_output\":  \"\",\n\t\t}\n\t}\n\n\treturn map[string]any{\n\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),","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/aiusechat/tools_builder.go#L45-L81","documentation":"parseBuilderWriteAppFileInput validates raw input for the builder write-app-file tool. A nil input cannot be unmarshaled into builderWriteAppFileParams, so nil is rejected immediately with this sentinel error before ReUnmarshal is attempted.","triggerScenarios":"The builder tool is invoked with input == nil: no arguments object supplied at all, or an upstream layer passes nil through when arguments parsing failed silently.","commonSituations":"LLM tool call with empty arguments; a dispatch layer that swallows JSON parse errors and forwards nil; calling the parse function directly in tests with a nil argument.","solutions":["Always pass a JSON object as tool input, at minimum {\"contents\": \"...\"}","Fix any upstream argument-decoding layer so it produces an empty map {} rather than nil on parse failure","If calling parseBuilderWriteAppFileInput directly (tests), pass map[string]any{\"contents\": ...} not nil"],"exampleFix":"// before\nparseBuilderWriteAppFileInput(nil)\n// after\nparseBuilderWriteAppFileInput(map[string]any{\"contents\": \"file body\"})","handlingStrategy":"validation","validationCode":"if input == nil { input = map[string]any{} }; if _, ok := input.(map[string]any); !ok { return errors.New(\"tool input must be an object\") }","typeGuard":"func nonNilObject(input any) (map[string]any, bool) { if input == nil { return nil, false }; m, ok := input.(map[string]any); return m, ok }","tryCatchPattern":"params, err := parseBuilderWriteAppFileInput(input); if err != nil { if err.Error() == \"input is required\" { input = map[string]any{} } else { return err } }","preventionTips":["Never forward nil tool arguments; default to an empty object","Fix dispatch layers to surface JSON decode errors instead of passing nil","Ensure tool calls always serialize an arguments object, even when minimal"],"tags":["tool-input","nil-input","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"}