santifer/career-ops · error
Refusing to write the cover letter outside output/
Error message
Refusing to write the cover letter outside output/: ${raw} What it means
safeOutputPath rejects paths that explicitly chose a location outside OUTPUT_ROOT: absolute paths, or relative paths containing a `..` segment, that resolve outside output/. Rather than silently rewriting such a path to a basename, it refuses with the raw value embedded, enforcing that generated cover letters can only be written into the output directory.
Solutions
- Use a bare filename or an output/-relative path: `--out cover.md` or `--out output/cover.md` from the repo root.
- Generate inside output/ and copy/move the file yourself afterwards.
- If you need a different destination directory, change OUTPUT_ROOT configuration rather than passing paths outside it.
Example fix
// before node generate-cover-letter.mjs --out /home/user/cover.md // after node generate-cover-letter.mjs --out cover.md && cp output/cover.md /home/user/
Defensive patterns
Strategy: validation
Validate before calling
import {isAbsolute} from 'path';
function isSafeRelOut(p) { return typeof p === 'string' && !isAbsolute(p) && !/(^|[\\/])\.\.([\\/]|$)/.test(p); } Type guard
const isInsideOutput = (abs, root) => { const rel = relative(root, abs); return rel !== '' && !rel.startsWith('..') && !isAbsolute(rel); }; Try / catch
try { const p = safeOutputPath(raw); } catch (e) { if (/Refusing to write the cover letter outside output/.test(e.message)) { console.error('Use a bare filename; it will be placed under output/'); process.exit(2); } throw e; } Prevention
- Treat output/ as the only writable destination; copy elsewhere afterwards.
- Never construct --out values with .. segments.
- In integrations, always pass bare filenames and let the tool resolve inside OUTPUT_ROOT.
When it happens
Trigger: `--out /home/user/cover.md` (absolute, outside output/); `--out ../cover.md` or `--out output/../secret.md` (traversal segment resolving outside OUTPUT_ROOT); payloads with output_path set to an absolute temp dir.
Common situations: A user tries to write the letter directly to ~/Desktop or a shared drive; a script builds a path with .. to a sibling directory; integration tests passing /tmp paths.
Understand the failure class
Background: Path traversal blocked: "path escapes the workspace" and "outside site root" errors when a path will not stay inside its allowed directory — this error's family across 26 libraries.
Related errors
- a 40-hex commit --sha is required
- arbeitnow: URL must use HTTPS
- eightfold: URL must use HTTPS
- H1B_INDEX_PATH is set but empty. Unset it to use the…
- justjoin: untrusted hostname
AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16).
Data as JSON: /api/errors/18e95d95a7f759f8.
Report an issue: GitHub.
Appendix: source
Thrown at generate-cover-letter.mjs:51
* would escape `output/` — `..` traversal or an absolute path outside it —
* are rejected instead of being silently flattened to `output/<basename>`.
*
* @param {string} raw - Caller-supplied --out / payload.output_path value.
* @returns {string} Absolute path inside OUTPUT_ROOT.
*/
export function safeOutputPath(raw) {
if (raw == null || String(raw).trim() === "") {
throw new Error("Refusing to write the cover letter outside output/: (empty path)");
}
const trimmed = String(raw).trim();
const asWritten = resolve(trimmed);
if (containedInOutput(asWritten)) return asWritten;
// Absolute paths and any `..` segment already chose a location; if that
// location is not inside output/, refuse instead of rewriting to a basename.
if (isAbsolute(trimmed) || /(^|[\\/])\.\.([\\/]|$)/.test(trimmed)) {
throw new Error(`Refusing to write the cover letter outside output/: ${raw}`);
}
// Bare filename or a relative path that is not already under output/
// (e.g. --out cover.pdf, or --out output/foo/bar.pdf from another cwd).
const posix = trimmed.replace(/\\/g, "/").replace(/^\.\//, "");
const relativeToRoot = posix === "output" || posix === "output/"
? ""
: posix.startsWith("output/")
? posix.slice("output/".length)
: posix;
const candidate = resolve(OUTPUT_ROOT, relativeToRoot);
if (containedInOutput(candidate)) return candidate;
throw new Error(`Refusing to write the cover letter outside output/: ${raw}`);
}
/** True when absPath is a file (not output/ itself) still inside OUTPUT_ROOT. */
function containedInOutput(absPath) {View on GitHub (pinned to aac998c7ed)