{"record":{"id":"8555801177f918e4","repo":"mislav/hub","slug":"this-gist-contains-multiple-files-you-must-specif","errorCode":null,"errorMessage":"This gist contains multiple files, you must specify one:\n  %s","messagePattern":"This gist contains multiple files, you must specify one:\n  (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/gist.go","lineNumber":92,"sourceCode":"func init() {\n\tcmdGist.Use(cmdShowGist)\n\tcmdGist.Use(cmdCreateGist)\n\tCmdRunner.Use(cmdGist)\n}\n\nfunc getGist(gh *github.Client, id string, filename string) error {\n\tgist, err := gh.FetchGist(id)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(gist.Files) > 1 && filename == \"\" {\n\t\tfilenames := []string{}\n\t\tfor name := range gist.Files {\n\t\t\tfilenames = append(filenames, name)\n\t\t}\n\t\tsort.Strings(filenames)\n\t\treturn fmt.Errorf(\"This gist contains multiple files, you must specify one:\\n  %s\", strings.Join(filenames, \"\\n  \"))\n\t}\n\n\tif filename != \"\" {\n\t\tif val, ok := gist.Files[filename]; ok {\n\t\t\tui.Println(val.Content)\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"no such file in gist\")\n\t\t}\n\t} else {\n\t\tfor name := range gist.Files {\n\t\t\tfile := gist.Files[name]\n\t\t\tui.Println(file.Content)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc printGistHelp(command *Command, args *Args) {","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/mislav/hub/blob/5c547ed804368763064e51f3990851e267e88edd/commands/gist.go#L74-L110","documentation":"`gist view`/`getGist` fetches a gist that contains more than one file, but no filename argument was supplied. Since the command cannot decide which file's content to print, it lists all file names sorted alphabetically and aborts. This is an interactive-disambiguation error: re-run naming one of the listed files.","triggerScenarios":"Calling `gh gist view <id>` (via showGist -> getGist) where the gist's `Files` map has length > 1 and the `filename` argument is empty.","commonSituations":"Pasting a gist URL that contains several files (common with multi-file gists); scripts that assumed single-file gists; gist was edited to add files after the script was written.","solutions":["Re-run the command with the desired file name: `gh gist view <id> <filename>`.","Pick one of the file names exactly as listed in the error message (it prints all valid options).","In scripts, capture the first listed name programmatically or loop over all files."],"exampleFix":"// before\ngh gist view abc123            # multi-file gist -> error\n// after\ngh gist view abc123 config.yml","handlingStrategy":"validation","validationCode":"// Fetch the gist and inspect file count before viewing\n gist := fetchGist(gistID)\nif len(gist.Files) > 1 && filename == \"\" {\n    for name := range gist.Files {\n        fmt.Println(name)\n    }\n    os.Exit(1) // force explicit file selection\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass a filename when viewing multi-file gists.","Copy file names exactly from `gh gist view <id>` output, including extension and case.","In scripts, assert single-file gists or iterate over all files explicitly."],"tags":["gist","missing-argument","cli-usage"],"backgroundTag":"ambiguous-target-requires-argument","analyzedSha":"5c547ed804368763064e51f3990851e267e88edd","analyzedAt":"2026-09-01T03:34:15.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}