{"record":{"id":"23741495144f89b1","repo":"cli/cli","slug":"no-files-passed","errorCode":null,"errorMessage":"no files passed","messagePattern":"no files passed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/gist/create/create.go","lineNumber":196,"sourceCode":"\t}\n\tfmt.Fprintf(errOut, \"%s %s\\n\", cs.SuccessIconWithColor(cs.Green), completionMessage)\n\n\tif opts.WebMode {\n\t\tfmt.Fprintf(opts.IO.Out, \"Opening %s in your browser.\\n\", text.DisplayURL(gist.HTMLURL))\n\n\t\treturn opts.Browser.Browse(gist.HTMLURL)\n\t}\n\n\tfmt.Fprintln(opts.IO.Out, gist.HTMLURL)\n\n\treturn nil\n}\n\nfunc processFiles(stdin io.ReadCloser, filenameOverride string, filenames []string) (map[string]*shared.GistFile, error) {\n\tfs := map[string]*shared.GistFile{}\n\n\tif len(filenames) == 0 {\n\t\treturn nil, errors.New(\"no files passed\")\n\t}\n\n\tfor i, f := range filenames {\n\t\tvar filename string\n\t\tvar content []byte\n\t\tvar err error\n\n\t\tif f == \"-\" {\n\t\t\tif filenameOverride != \"\" {\n\t\t\t\tfilename = filenameOverride\n\t\t\t} else {\n\t\t\t\tfilename = fmt.Sprintf(\"gistfile%d.txt\", i)\n\t\t\t}\n\t\t\tcontent, err = io.ReadAll(stdin)\n\t\t\tif err != nil {\n\t\t\t\treturn fs, fmt.Errorf(\"failed to read from stdin: %w\", err)\n\t\t\t}\n\t\t\tstdin.Close()","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/cli/cli/blob/0eeec0b92edbe70199f9768522f831d3534f41ad/pkg/cmd/gist/create/create.go#L178-L214","documentation":"Thrown by processFiles in gh gist create when the filenames slice is empty. The gist creation API requires at least one file, and this guard fires before any network call. It means the command was invoked with no positional file arguments and no stdin content routed in.","triggerScenarios":"Running `gh gist create` with zero positional arguments and no `-` (stdin) file; programmatic invocations that build an args slice from a glob or variable that evaluates to empty.","commonSituations":"Shell scripts where a glob like *.log matches nothing (nullglob off, it passes a literal, but with nullglob it passes nothing); CI jobs generating gists from optional artifacts; wrapping gh in a tool that forwards an empty file list.","solutions":["Pass at least one filename or `-` to read from stdin: `gh gist create -` < file.txt","In scripts, check the file list is non-empty before invoking gh: `if [ ${#files[@]} -gt 0 ]; then gh gist create \"${files[@]}\"; fi`","When forwarding stdin, remember `gh gist create -` is required; bare `gh gist create` never reads stdin implicitly"],"exampleFix":"# before\ngh gist create \"${files[@]}\"\n# after\n[ ${#files[@]} -gt 0 ] && gh gist create \"${files[@]}\" || echo \"no files to gist\"","handlingStrategy":"validation","validationCode":"# bash: ensure at least one file argument\nfiles=(\"$@\")\n[ ${#files[@]} -gt 0 ] || { echo \"refusing: no files to gist\" >&2; exit 1; }\ngh gist create \"${files[@]}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never invoke gh gist create with an unguarded glob; verify the array length first","Use `gh gist create -` explicitly when feeding stdin rather than assuming implicit reads","In wrapper functions, fail fast with a clear message when the file list is empty"],"tags":["gist","cli","validation","arguments"],"backgroundTag":null,"analyzedSha":"0eeec0b92edbe70199f9768522f831d3534f41ad","analyzedAt":"2026-08-15T12:31:05.478Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}