{"record":{"id":"564cbb47627aa446","repo":"affaan-m/ECC","slug":"refusing-to-action-target-no-trusted-inst","errorCode":null,"errorMessage":"Refusing to ${action} '${target}': no trusted install root resolved.","messagePattern":"Refusing to (.+?) '(.+?)': no trusted install root resolved\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/path-safety.js","lineNumber":90,"sourceCode":"  }\n\n  try {\n    return resolveContainment(target, root).contained;\n  } catch {\n    return false;\n  }\n}\n\n/**\n * Fail-closed guard: throw unless `target` is contained within `root`.\n * Returns the canonicalized target path on success.\n */\nfunction assertWithinTrustedRoot(target, root, action = 'write') {\n  if (!target || typeof target !== 'string') {\n    throw new Error(`Refusing to ${action}: missing destination path.`);\n  }\n  if (!root) {\n    throw new Error(`Refusing to ${action} '${target}': no trusted install root resolved.`);\n  }\n\n  let containment;\n  try {\n    containment = resolveContainment(target, root);\n  } catch {\n    containment = null;\n  }\n  if (!containment || !containment.contained) {\n    throw new Error(`Refusing to ${action} outside the install root: '${target}' is not within '${root}'.`);\n  }\n  return containment.realTarget;\n}\n\nmodule.exports = {\n  realpathNearestExisting,\n  isWithinRoot,\n  assertWithinTrustedRoot","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/path-safety.js#L72-L108","documentation":"Thrown by assertWithinTrustedRoot when `target` is a valid string but `root` (the trusted install root) is falsy. The guard cannot confine a path without a trusted root to confine against, so it fails closed rather than defaulting to cwd or any implicit base.","triggerScenarios":"Calling assertWithinTrustedRoot(dest, undefined, 'write'), assertWithinTrustedRoot(dest, '', 'write'), or passing a root derived from an adapter that returned null because no trusted root could be resolved for the current harness.","commonSituations":"An adapter (claude/cursor/codex) failing to resolve its target directory; a multi-harness setup where the harness type is unset so no root maps; running an install-lifecycle operation outside a project; a config migration that left the root resolution returning empty.","solutions":["Resolve and verify a trusted root before invoking any install/repair/uninstall operation.","Fail early with a clear error if no adapter root is available, instead of passing undefined downstream.","Check isWithinRoot(target, root) returns false rather than calling assert when root may be absent.","Ensure the harness/adapter is configured (e.g. CLAUDE_CONFIG_DIR) so the root resolves."],"exampleFix":"// before\nconst trustedRoot = adapter.resolveRoot(); // returns undefined\nassertWithinTrustedRoot(dest, trustedRoot, 'write');\n\n// after\nconst trustedRoot = adapter.resolveRoot();\nif (!trustedRoot) throw new Error('No trusted install root for harness ' + adapter.id);\nassertWithinTrustedRoot(dest, trustedRoot, 'write');","handlingStrategy":"validation","validationCode":"if (!root) throw new Error('No trusted install root resolved; configure the adapter.');\nassertWithinTrustedRoot(target, root, action);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve and verify a trusted root before any install-lifecycle operation.","Fail early with a clear error if the adapter cannot resolve its root.","Ensure harness/adapter config (e.g. CLAUDE_CONFIG_DIR) is set."],"tags":["security","path-traversal","install-safety","configuration"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}