{"record":{"id":"f3f9a5c5aad1a73b","repo":"benweet/stackedit","slug":"gist-file-not-found","errorCode":null,"errorMessage":"Gist file not found.","messagePattern":"Gist file not found\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/services/providers/helpers/githubHelper.js","lineNumber":282,"sourceCode":"        public: isPublic,\n      },\n    });\n    return body;\n  },\n\n  /**\n   * https://developer.github.com/v3/gists/#get-a-single-gist\n   */\n  async downloadGist({\n    token,\n    gistId,\n    filename,\n  }) {\n    const result = (await request(token, {\n      url: `https://api.github.com/gists/${gistId}`,\n    })).body.files[filename];\n    if (!result) {\n      throw new Error('Gist file not found.');\n    }\n    return result.content;\n  },\n\n  /**\n   * https://developer.github.com/v3/gists/#list-gist-commits\n   */\n  async getGistCommits({\n    token,\n    gistId,\n  }) {\n    const { body } = await request(token, {\n      url: `https://api.github.com/gists/${gistId}/commits`,\n    });\n    return body;\n  },\n\n  /**","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/benweet/stackedit/blob/6dce2a5e36b755a0c244522b48a06c91a2df0f59/src/services/providers/helpers/githubHelper.js#L264-L300","documentation":"downloadGist fetches a GitHub Gist via the API and looks up the requested filename in the response's files map. If the gist has no file with that exact name, githubHelper throws 'Gist file not found.' at src/services/providers/helpers/githubHelper.js:282. GitHub gist file names must match exactly, including extension, so a typo or renamed file triggers this.","triggerScenarios":"`(await request(token, { url: 'https://api.github.com/gists/<gistId>' })).body.files[filename]` is undefined: filename misspelled, file renamed/deleted in the gist, or the gistId points to a different gist.","commonSituations":"Publishing/importing a file whose gist counterpart was renamed on github.com; private gists becoming unavailable after the author's account changes; stale workspace config referencing an old gist ID; case-sensitivity mismatch in filename.","solutions":["Verify the filename matches exactly (case and extension) a file present in the gist on github.com.","Verify the gist ID; open https://gist.github.com/<gistId> to confirm it exists and contains the file.","If the file was renamed, update the stored reference to the new filename.","Handle 404/expired gists by re-importing or re-publishing the file."],"exampleFix":"// before\nif (!result) {\n  throw new Error('Gist file not found.');\n}\n// after\nif (!result) {\n  const available = Object.keys(((await request(token, { url: `https://api.github.com/gists/${gistId}` })).body.files) || {}).join(', ');\n  throw new Error(`Gist file not found: '${filename}'. Available files: ${available}`);\n}","handlingStrategy":"validation","validationCode":"async function gistHasFile(token, gistId, filename) {\n  const { body } = await request(token, { url: `https://api.github.com/gists/${gistId}` });\n  return Object.prototype.hasOwnProperty.call(body.files || {}, filename);\n}","typeGuard":"function isGistFileEntry(entry) {\n  return entry && typeof entry.content === 'string' && typeof entry.raw_url === 'string';\n}","tryCatchPattern":"try {\n  const content = await githubHelper.downloadGist({ token, gistId, filename });\n} catch (err) {\n  if (/Gist file not found/i.test(err.message)) {\n    promptUserToVerifyGistIdAndFilename(err);\n  }\n}","preventionTips":["Verify gist ID and exact filename (case-sensitive, with extension) before importing.","Store the gist's actual filename from the API at publish time instead of a hand-typed one.","Watch for renames/deletions of gist files and refresh references.","Handle 404/expired gists by re-publishing and updating stored IDs."],"tags":["github","gist","not-found"],"backgroundTag":"remote-file-not-found","analyzedSha":"6dce2a5e36b755a0c244522b48a06c91a2df0f59","analyzedAt":"2026-09-01T00:49:23.866Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}