{"record":{"id":"ba4df97b99681013","repo":"santifer/career-ops","slug":"addpaths-received-directory-pathspec-s-which-f-would-sweep","errorCode":null,"errorMessage":"addPaths received directory pathspec(s), which -f would sweep ignored files from: ${dirs.join(', ')}. Resolve them with expandToShippedFiles() first.","messagePattern":"addPaths received directory pathspec\\(s\\), which -f would sweep ignored files from: (.+?)\\. Resolve them with expandToShippedFiles\\(\\) first\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"update-system.mjs","lineNumber":1612,"sourceCode":" * `node_modules` (no index entries at all, yet fully sweepable).\n *\n * @param {string[]} paths - Repo-relative paths about to be force-added.\n * @param {string} root - Repository root; injectable so the test seam resolves\n *   against its fixture instead of the module-level ROOT.\n */\nfunction rejectDirectories(paths, root) {\n  const dirs = paths.filter(p => {\n    if (p.endsWith('/')) return true;\n    try {\n      return lstatSync(join(root, p)).isDirectory();\n    } catch {\n      // Absent from the worktree: a staged deletion, or a file this run is\n      // about to create. Neither can recurse.\n      return false;\n    }\n  });\n  if (dirs.length > 0) {\n    throw new Error(\n      `addPaths received directory pathspec(s), which -f would sweep ignored files from: ` +\n      `${dirs.join(', ')}. Resolve them with expandToShippedFiles() first.`\n    );\n  }\n}\n\n// Git's \"exclude this from the pathspec\" magic prefix. Preserved files are held\n// out of the checkout, the staging and the scoped commit with it, so the one\n// place that has to recognise such an entry again — the index-commit guard —\n// reads the prefix from here rather than re-spelling it.\nconst EXCLUDE_PATHSPEC_PREFIX = ':(exclude)';\n\n/**\n * The concrete FILE list to stage and scope-commit for an update.\n *\n * `pathsToStage` is a git PATHSPEC list: positive manifest entries (files, and\n * directory entries ending in '/') plus `:(exclude)<path>` specs for files this\n * install preserved (#2337). Two consumers need a plain file list, not that","sourceCodeStart":1594,"sourceCodeEnd":1630,"githubUrl":"https://github.com/santifer/career-ops/blob/e7abd431fce9348a95261acac9e0c14779c35df8/update-system.mjs#L1594-L1630","documentation":"update-system.mjs's addPaths helper stages paths with `git add -f`, which force-adds even gitignored files. Because directories cannot be safely force-added (a whole ignored tree could be swept in), the helper rejects any directory pathspec outright. The caller is expected to expand directories to their concrete shipped files first via expandToShippedFiles(), which recurses only into files the update actually manages.","triggerScenarios":"Calling addPaths() with a path that resolves to a directory (e.g. a manifest entry pointing at a directory, or a file deleted from the worktree so its parent dir lookup fails to resolve as a file) during an apply run.","commonSituations":"A system-layer manifest or config lists a directory instead of individual files; a file this run is about to create is passed as its not-yet-existing path and resolves as a directory-ish pathspec; custom edits to the file manifest replaced a file list with a folder.","solutions":["Expand the directory into individual file paths with expandToShippedFiles() before calling addPaths().","Fix the manifest/config entry so it lists concrete file paths, not directories.","If the path is a file this run creates, ensure it is passed as the exact file path, not a parent directory or glob."],"exampleFix":"// before\naddPaths(['modes/']);\n// after\naddPaths(expandToShippedFiles(['modes/']));","handlingStrategy":"validation","validationCode":"import { statSync } from 'node:fs';\nconst dirs = paths.filter(p => { try { return statSync(p).isDirectory(); } catch { return false; } });\nif (dirs.length) throw new Error(`expand directories first: ${dirs.join(', ')}`);\naddPaths(expandToShippedFiles(paths));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always funnel path lists through expandToShippedFiles() before addPaths().","Keep manifests as explicit file lists, never directories or globs.","Add a unit test asserting addPaths throws on a directory fixture."],"tags":["git","internal-invariant","updater"],"backgroundTag":"invalid-argument-value","analyzedSha":"e7abd431fce9348a95261acac9e0c14779c35df8","analyzedAt":"2026-09-16T06:35:29.214Z","contentChangedAt":"2026-09-16T06:35:29.214Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}