{"record":{"id":"4c9a1a22f092810f","repo":"wavetermdev/waveterm","slug":"no-files-or-message-provided","errorCode":null,"errorMessage":"no files or message provided","messagePattern":"no files or message provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/wsh/cmd/wshcmd-ai.go","lineNumber":76,"sourceCode":"\nfunc getMaxFileSize(mimeType string) (int, string) {\n\tif mimeType == \"application/pdf\" {\n\t\treturn 5 * 1024 * 1024, \"5MB\"\n\t}\n\tif strings.HasPrefix(mimeType, \"image/\") {\n\t\treturn 7 * 1024 * 1024, \"7MB\"\n\t}\n\treturn 200 * 1024, \"200KB\"\n}\n\nfunc aiRun(cmd *cobra.Command, args []string) (rtnErr error) {\n\tdefer func() {\n\t\tsendActivity(\"ai\", rtnErr == nil)\n\t}()\n\n\tif len(args) == 0 && aiMessageFlag == \"\" {\n\t\tOutputHelpMessage(cmd)\n\t\treturn fmt.Errorf(\"no files or message provided\")\n\t}\n\n\tconst maxFileCount = 15\n\tconst rpcTimeout = 30000\n\n\tvar allFiles []wshrpc.AIAttachedFile\n\tvar stdinUsed bool\n\n\tif len(args) > maxFileCount {\n\t\treturn fmt.Errorf(\"too many files (maximum %d files allowed)\", maxFileCount)\n\t}\n\n\tfor _, filePath := range args {\n\t\tvar data []byte\n\t\tvar fileName string\n\t\tvar mimeType string\n\t\tvar err error\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-ai.go#L58-L94","documentation":"The `wsh ai` command requires either file arguments to attach or a message via the -m/--message flag. When invoked with neither, it prints help and returns this error so the CLI exits non-zero, telling the user the invocation was empty.","triggerScenarios":"Running `wsh ai` with no positional file args and aiMessageFlag empty (no -m flag); also supplying more than maxFileCount files or oversized files will error separately, but this specific error is the empty-invocation case.","commonSituations":"Typing `wsh ai` bare to 'test' the command; scripting wsh ai without passing -m or files; forgetting the flag because a positional message was expected.","solutions":["Provide a message: `wsh ai -m \"explain this error\"`.","Attach files positionally: `wsh ai main.go README.md`.","Combine both: `wsh ai -m \"review this\" main.go`.","Run `wsh ai --help` (OutputHelpMessage is shown with the error) to see required flags.","In scripts, assert non-empty args before invoking wsh ai."],"exampleFix":"// before\nwsh ai\n// Error: no files or message provided\n// after\nwsh ai -m \"summarize this project\"","handlingStrategy":"validation","validationCode":"if len(args) == 0 && aiMessageFlag == \"\" {\n    return fmt.Errorf(\"wsh ai needs -m <message> or file arguments\")\n}","typeGuard":null,"tryCatchPattern":"if err := runAi(cmd, args); err != nil {\n    cmd.SilenceUsage = false\n    return err // help message already printed\n}","preventionTips":["Always pass -m or at least one file to `wsh ai`.","Check `wsh ai --help` before scripting new invocations.","Validate arguments in wrapper scripts before calling wsh.","Remember the 15-file and size limits when attaching."],"tags":["cli","wsh","user-input"],"backgroundTag":"missing-required-argument","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}