{"record":{"id":"9fb8d0ee4112b969","repo":"Fission-AI/OpenSpec","slug":"refusing-to-manage-an-artifact-outside-the-project","errorCode":null,"errorMessage":"Refusing to manage an artifact outside the project: ${artifactPath}","messagePattern":"Refusing to manage an artifact outside the project: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/utils/file-system.ts","lineNumber":129,"sourceCode":"   */\n  static assertPathWithin(allowedDirectory: string, targetPath: string): void {\n    const resolvedDirectory = path.resolve(allowedDirectory);\n    const resolvedTarget = path.resolve(targetPath);\n\n    if (!this.isPathWithin(resolvedDirectory, resolvedTarget)) {\n      throw new Error(`Path is outside the allowed directory: ${targetPath}`);\n    }\n\n    const canonicalDirectory = this.canonicalizePotentialPath(resolvedDirectory);\n    const canonicalTarget = this.canonicalizePotentialPath(resolvedTarget);\n    if (!this.isPathWithin(canonicalDirectory, canonicalTarget)) {\n      throw new Error(`Path is outside the allowed directory: ${targetPath}`);\n    }\n  }\n\n  static resolveProjectArtifactPath(projectPath: string, artifactPath: string): string {\n    if (path.isAbsolute(artifactPath)) {\n      throw new Error(`Refusing to manage an artifact outside the project: ${artifactPath}`);\n    }\n\n    const targetPath = path.join(projectPath, artifactPath);\n    this.assertPathWithin(projectPath, targetPath);\n    return targetPath;\n  }\n\n  static assertProjectArtifactPath(projectPath: string, targetPath: string): void {\n    this.assertPathWithin(projectPath, targetPath);\n  }\n\n  private static isPathWithin(allowedDirectory: string, targetPath: string): boolean {\n    const relative = path.relative(allowedDirectory, targetPath);\n    return (\n      relative === '' ||\n      (relative !== '..' &&\n        !relative.startsWith(`..${path.sep}`) &&\n        !path.isAbsolute(relative))","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/Fission-AI/OpenSpec/blob/6926ccb18afa4ff621112813e9968334576ee11a/src/utils/file-system.ts#L111-L147","documentation":"Error \"Refusing to manage an artifact outside the project: ${artifactPath}\" thrown in Fission-AI/OpenSpec.","triggerScenarios":"Thrown at src/utils/file-system.ts:129 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6926ccb18afa4ff621112813e9968334576ee11a","analyzedAt":"2026-08-25T12:29:45.729Z","schemaVersion":2},"datasetVersion":"2026-08-25T16:17:27.014Z"}