benweet/stackedit · error · Error
Gist file not found.
Error message
Gist file not found.
What it means
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.
Source
Thrown at src/services/providers/helpers/githubHelper.js:282
public: isPublic,
},
});
return body;
},
/**
* https://developer.github.com/v3/gists/#get-a-single-gist
*/
async downloadGist({
token,
gistId,
filename,
}) {
const result = (await request(token, {
url: `https://api.github.com/gists/${gistId}`,
})).body.files[filename];
if (!result) {
throw new Error('Gist file not found.');
}
return result.content;
},
/**
* https://developer.github.com/v3/gists/#list-gist-commits
*/
async getGistCommits({
token,
gistId,
}) {
const { body } = await request(token, {
url: `https://api.github.com/gists/${gistId}/commits`,
});
return body;
},
/**View on GitHub (pinned to 6dce2a5e36)
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.
Example fix
// before
if (!result) {
throw new Error('Gist file not found.');
}
// after
if (!result) {
const available = Object.keys(((await request(token, { url: `https://api.github.com/gists/${gistId}` })).body.files) || {}).join(', ');
throw new Error(`Gist file not found: '${filename}'. Available files: ${available}`);
} Defensive patterns
Strategy: validation
Validate before calling
async function gistHasFile(token, gistId, filename) {
const { body } = await request(token, { url: `https://api.github.com/gists/${gistId}` });
return Object.prototype.hasOwnProperty.call(body.files || {}, filename);
} Type guard
function isGistFileEntry(entry) {
return entry && typeof entry.content === 'string' && typeof entry.raw_url === 'string';
} Try / catch
try {
const content = await githubHelper.downloadGist({ token, gistId, filename });
} catch (err) {
if (/Gist file not found/i.test(err.message)) {
promptUserToVerifyGistIdAndFilename(err);
}
} Prevention
- 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.
When it happens
Trigger: `(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.
Common situations: 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.
Related errors
AI-assisted analysis of benweet/stackedit@6dce2a5e36 (2026-09-01).
Data as JSON: /api/errors/f3f9a5c5aad1a73b.
Report an issue: GitHub.