Fission-AI/OpenSpec · error · Error
Refusing to manage an artifact outside the project
Error message
Refusing to manage an artifact outside the project: ${artifactPath} What it means
Thrown by assertPathWithin's second, canonicalized check when the target stays inside the allowed directory textually but escapes it after resolving symlinks (realpath). The guard refuses to manage project artifacts that canonically live outside the project.
Solutions
- Remove or repoint symlinks in the target path that escape the project
- Use a real path inside the project directory
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/utils/file-system.ts:129 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Fission-AI/OpenSpec@6926ccb18a (2026-08-25).
Data as JSON: /api/errors/9fb8d0ee4112b969.
Report an issue: GitHub.
Appendix: source
Thrown at src/utils/file-system.ts:129
*/
static assertPathWithin(allowedDirectory: string, targetPath: string): void {
const resolvedDirectory = path.resolve(allowedDirectory);
const resolvedTarget = path.resolve(targetPath);
if (!this.isPathWithin(resolvedDirectory, resolvedTarget)) {
throw new Error(`Path is outside the allowed directory: ${targetPath}`);
}
const canonicalDirectory = this.canonicalizePotentialPath(resolvedDirectory);
const canonicalTarget = this.canonicalizePotentialPath(resolvedTarget);
if (!this.isPathWithin(canonicalDirectory, canonicalTarget)) {
throw new Error(`Path is outside the allowed directory: ${targetPath}`);
}
}
static resolveProjectArtifactPath(projectPath: string, artifactPath: string): string {
if (path.isAbsolute(artifactPath)) {
throw new Error(`Refusing to manage an artifact outside the project: ${artifactPath}`);
}
const targetPath = path.join(projectPath, artifactPath);
this.assertPathWithin(projectPath, targetPath);
return targetPath;
}
static assertProjectArtifactPath(projectPath: string, targetPath: string): void {
this.assertPathWithin(projectPath, targetPath);
}
private static isPathWithin(allowedDirectory: string, targetPath: string): boolean {
const relative = path.relative(allowedDirectory, targetPath);
return (
relative === '' ||
(relative !== '..' &&
!relative.startsWith(`..${path.sep}`) &&
!path.isAbsolute(relative))View on GitHub (pinned to 6926ccb18a)