{"record":{"id":"cabbf540aa0addae","repo":"mislav/hub","slug":"no-such-file-in-gist","errorCode":null,"errorMessage":"no such file in gist","messagePattern":"no such file in gist","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/gist.go","lineNumber":99,"sourceCode":"\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) {\n\tutils.Check(command.UsageError(\"\"))\n}\n\nfunc createGist(cmd *Command, args *Args) {\n\targs.NoForward()\n\n\thost, err := github.CurrentConfig().DefaultHostNoPrompt()","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/mislav/hub/blob/5c547ed804368763064e51f3990851e267e88edd/commands/gist.go#L81-L117","documentation":"`getGist` was given an explicit filename that does not exist in the fetched gist's `Files` map. The gist itself is valid and reachable; only the file key lookup failed. File names are case-sensitive and must match exactly as stored on GitHub.","triggerScenarios":"Running `gh gist view <gist-id> <filename>` (showGist -> getGist) where `gist.Files[filename]` is absent — typo, wrong case, missing extension, or file deleted from the gist.","commonSituations":"Typos or case mismatch (README.md vs readme.md); omitting the file extension; the file was removed from the gist after the command/script was written; copy-pasting a name from a different gist.","solutions":["Run `gh gist view <gist-id>` without a filename to see the exact list of file names, then use one verbatim.","Check spelling and case — file keys are case-sensitive, including the extension.","Re-fetch the gist to confirm the file still exists; it may have been edited/deleted."],"exampleFix":"// before\ngh gist view abc123 readme.md   # actual file is README.md\n// after\ngh gist view abc123 README.md","handlingStrategy":"validation","validationCode":"gist := fetchGist(gistID)\nif _, ok := gist.Files[filename]; !ok {\n    fmt.Printf(\"available files: \")\n    for name := range gist.Files {\n        fmt.Printf(\"%s \", name)\n    }\n    fmt.Println()\n    os.Exit(1)\n}","typeGuard":"func fileInGist(gist *github.Gist, name string) bool {\n    _, ok := gist.Files[name]\n    return ok\n}","tryCatchPattern":null,"preventionTips":["List gist files first (`gh gist view <id>`) and use names verbatim.","Remember file lookups are case-sensitive and require the exact extension.","Re-check gists referenced in scripts — files can be edited or removed."],"tags":["gist","not-found","cli-usage"],"backgroundTag":"key-not-found","analyzedSha":"5c547ed804368763064e51f3990851e267e88edd","analyzedAt":"2026-09-01T03:34:15.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}