{"record":{"id":"2a91360260daadad","repo":"abhigyanpatwari/GitNexus","slug":"gitnexus-unable-to-verify-main-db-file-before-orp","errorCode":null,"errorMessage":"GitNexus: unable to verify main DB file before orphan sidecar cleanup (${code ?? 'UNKNOWN'}); skipping cleanup: ${summarizeError(err)}","messagePattern":"GitNexus: unable to verify main DB file before orphan sidecar cleanup \\((.+?)\\); skipping cleanup: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/lbug/lbug-adapter.ts","lineNumber":893,"sourceCode":"          for (const sidecar of orphanSidecars) {\n            try {\n              await fs.unlink(sidecar);\n              logger.warn(\n                `GitNexus: removed orphan sidecar ${path.basename(sidecar)} (no main DB file present)`,\n              );\n            } catch (err) {\n              if (isMissingFileError(err)) {\n                continue;\n              }\n              const code = extractErrnoCode(err);\n              logger.warn(\n                `GitNexus: failed to remove orphan sidecar ${path.basename(sidecar)} (${code ?? 'UNKNOWN'}) while main DB file is missing; LadybugDB open may still fail: ${summarizeError(err)}`,\n              );\n            }\n          }\n        } else {\n          const code = extractErrnoCode(err);\n          logger.warn(\n            `GitNexus: unable to verify main DB file before orphan sidecar cleanup (${code ?? 'UNKNOWN'}); skipping cleanup: ${summarizeError(err)}`,\n          );\n        }\n      }\n\n      // Ensure parent directory exists\n      const parentDir = path.dirname(dbPath);\n      await fs.mkdir(parentDir, { recursive: true });\n      await preflightLbugSidecars(dbPath, {\n        mode: 'write',\n        logger,\n        allowQuarantine: true,\n      });\n\n      const opened = await openLbugConnection(lbug, dbPath);\n      db = opened.db;\n      conn = opened.conn;\n      currentDbReadOnly = false;","sourceCodeStart":875,"sourceCodeEnd":911,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/0d1aed942f0e8b5d3bac27519fff441aceea722d/gitnexus/src/core/lbug/lbug-adapter.ts#L875-L911","documentation":"Preflight calls fs.access(dbPath) to decide whether orphan-sidecar cleanup is safe; the access failed with an error other than ENOENT (e.g. EACCES on a parent directory, ELOOP, EIO). Because the code cannot prove the main DB file's state, it skips cleanup entirely and warns — the open that follows may then trip over sidecars it dared not remove.","triggerScenarios":"A path component of dbPath lacks execute/search permission, dbPath is a symlink loop, or the filesystem returns EIO; anything except a clean 'file missing' answer. The else-branch fires exactly when isMissingFileError(err) is false.","commonSituations":"DB directories with restrictive modes (700 owned by another user), broken symlinks in the path after repo moves, NFS/overlayfs transient faults in containers, SELinux/AppArmor denials.","solutions":["Verify reachability of every path component: `namei -l <dbPath>` shows where permission fails; chmod the offending directory.","Fix or remove broken symlinks in the .gitnexus path after moving a repo.","Re-run once transient FS faults clear; if it recurs on network storage, move the DB to local disk."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before analyze: every path component must be searchable by this user\nimport { access } from 'node:fs/promises';\nfor (let dir = path.dirname(dbPath); ; dir = path.dirname(dir)) {\n  await access(dir, fsConstants.X_OK);\n  if (dir === path.dirname(dir)) break;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run namei -l on the DB path when opens behave oddly — it pinpoints the denied component.","Avoid symlink loops / stale links in .gitnexus paths after repo moves.","Prefer local disk over NFS/overlay for the index DB."],"tags":["filesystem","permissions","ladybugdb","preflight","eacces"],"backgroundTag":"file-access-denied","analyzedSha":"0d1aed942f0e8b5d3bac27519fff441aceea722d","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}