{"record":{"id":"b1bc20b2b334fb9c","repo":"cli/cli","slug":"no-file-in-the-gist","errorCode":null,"errorMessage":"no file in the gist","messagePattern":"no file in the gist","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/gist/edit/edit.go","lineNumber":265,"sourceCode":"\t\treturn updateGist(apiClient, host, gistToUpdate)\n\t}\n\n\tfilesToUpdate := map[string]string{}\n\n\tfor {\n\t\tfilename := opts.EditFilename\n\t\tcandidates := []string{}\n\t\tfor filename := range gistToUpdate.Files {\n\t\t\tcandidates = append(candidates, filename)\n\t\t}\n\n\t\tsort.Strings(candidates)\n\n\t\tif filename == \"\" {\n\t\t\tif len(candidates) == 1 {\n\t\t\t\tfilename = candidates[0]\n\t\t\t} else if len(candidates) == 0 {\n\t\t\t\treturn errors.New(\"no file in the gist\")\n\t\t\t} else {\n\t\t\t\tif !opts.IO.CanPrompt() {\n\t\t\t\t\treturn errors.New(\"unsure what file to edit; either specify --filename or run interactively\")\n\t\t\t\t}\n\t\t\t\tresult, err := opts.Prompter.Select(\"Edit which file?\", \"\", candidates)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"could not prompt: %w\", err)\n\t\t\t\t}\n\t\t\t\tfilename = candidates[result]\n\t\t\t}\n\t\t}\n\n\t\tgistFile, found := gistToUpdate.Files[filename]\n\t\tif !found {\n\t\t\treturn fmt.Errorf(\"gist has no file %q\", filename)\n\t\t}\n\t\tif shared.IsBinaryContents([]byte(gistFile.Content)) {\n\t\t\treturn fmt.Errorf(\"editing binary files not supported\")","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/cli/cli/blob/0eeec0b92edbe70199f9768522f831d3534f41ad/pkg/cmd/gist/edit/edit.go#L247-L283","documentation":"Thrown by gh gist edit when --filename was not supplied and the fetched gist's Files map contains zero entries. A gist with no files cannot have anything edited, so the file-selection logic bails out with this error.","triggerScenarios":"Editing a gist from which every file has previously been deleted (the GitHub API allows a gist to end up with an empty file map); racing against another client that deleted the files between fetch and edit.","commonSituations":"Automation that deletes all files from a gist via repeated gh gist edit --remove calls and then tries a subsequent edit; gists emptied by a collaborator before your edit command runs.","solutions":["Check the gist still has files: `gh gist view <id>` or `gh api gists/<id> --jq '.files | keys'","If the gist is intentionally empty, delete and recreate it with `gh gist create` instead of editing","Recreate the deleted content by adding a file: `gh gist edit <id> --filename new.txt` with content supplied appropriately"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"count=$(gh api gists/$GIST_ID --jq '.files | length')\n[ \"$count\" -gt 0 ] || { echo \"gist has no files; recreate instead\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Audit scripts that chain --remove operations; the last removal can empty the gist","Check `.files | length` via the REST API before editing","Treat an empty gist as a deleted resource: recreate rather than edit"],"tags":["gist","edit","empty-state","cli"],"backgroundTag":null,"analyzedSha":"0eeec0b92edbe70199f9768522f831d3534f41ad","analyzedAt":"2026-08-15T12:31:05.478Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}