{"record":{"id":"dbe4a41fd564a6b2","repo":"jackwener/OpenCLI","slug":"file-path-does-not-exist-filepath","errorCode":null,"errorMessage":"--file path does not exist: ${filePath}","messagePattern":"--file path does not exist: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/notebooklm/add-source.js","lineNumber":45,"sourceCode":"    '.epub': 'application/epub+zip',\n    '.mp3': 'audio/mpeg',\n    '.m4a': 'audio/mp4',\n    '.wav': 'audio/wav',\n};\n\nexport function inferMimeType(filename, override) {\n    if (override) return String(override);\n    const ext = path.extname(filename).toLowerCase();\n    return MIME_BY_EXT[ext] || 'application/octet-stream';\n}\n\nexport function readFileForUpload(filePath) {\n    const abs = path.resolve(filePath);\n    let stat;\n    try {\n        stat = fs.statSync(abs);\n    } catch {\n        throw new ArgumentError(`--file path does not exist: ${filePath}`);\n    }\n    if (!stat.isFile()) {\n        throw new ArgumentError(`--file path is not a regular file: ${filePath}`);\n    }\n    if (stat.size > MAX_FILE_SOURCE_BYTES) {\n        throw new ArgumentError(`--file exceeds ${MAX_FILE_SOURCE_BYTES} bytes (got ${stat.size}); use a smaller file or upload via the NotebookLM UI for now.`);\n    }\n    const buf = fs.readFileSync(abs);\n    return { base64: buf.toString('base64'), filename: path.basename(abs), size: stat.size };\n}\n\nexport function buildRegisterFileSourceArgs(projectId, filename) {\n    return [\n        [[filename]],\n        projectId,\n        [2],\n        [1, null, null, null, null, null, null, null, null, null, [1]],\n    ];","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/notebooklm/add-source.js#L27-L63","documentation":"readFileForUpload throws this ArgumentError when fs.statSync fails on the resolved --file path, meaning the path cannot be stated (does not exist, is inaccessible, or a broken symlink). The library validates the file before reading/base64-encoding it for a NotebookLM upload, and this is the first guard in that chain.","triggerScenarios":"Calling the add-source command with --file pointing to a non-existent path, a typo'd filename, a dangling symlink, or a path the process lacks permission to stat (statSync throws).","commonSituations":"Relative path typed from a different working directory than expected; file deleted or renamed before the command ran; shell quoting issues truncating the path; running on a machine/container where the file was never mounted.","solutions":["Check the path with `ls -l <path>` (or fs.existsSync) and correct typos.","Run the command from the directory you assumed, or pass an absolute path.","Verify file permissions and that the symlink target exists.","Confirm the file exists in the environment (container/mount) where the command executes."],"exampleFix":"// before\naddSource({ file: './nots/report.pdf' });\n// after\naddSource({ file: './notes/report.pdf' }); // or path.resolve to an absolute path","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nif (!fs.existsSync(filePath)) throw new Error(`--file not found: ${filePath}`);\nif (!fs.statSync(filePath).isFile()) throw new Error(`--file is not a regular file: ${filePath}`);","typeGuard":"function isExistingFile(p) { try { return fs.statSync(p).isFile(); } catch { return false; } }","tryCatchPattern":"try {\n  await addSource({ file: filePath });\n} catch (e) {\n  if (e instanceof ArgumentError && e.message.includes('--file path does not exist')) {\n    console.error(`Fix the path: ${path.resolve(filePath)}`);\n  } else throw e;\n}","preventionTips":["Always pass absolute paths (path.resolve) so cwd doesn't matter.","Check fs.existsSync + isFile before invoking the command.","Quote paths in the shell to avoid truncation on spaces.","Watch for broken symlinks when paths are generated by scripts."],"tags":["filesystem","argument-validation","notebooklm","file-upload"],"backgroundTag":"file-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}