Fission-AI/OpenSpec · error · ArchiveBlockedError
archive_target_exists
archive_target_exists
Error message
Archive '${path.basename(dest)}' already exists. What it means
Thrown by moveDirectory when rename fails with ENOTEMPTY/EEXIST: the archive destination was created (likely by a concurrent run) between the pre-flight check and the rename. Sentinel ArchiveBlockedError (archive_target_exists) telling the user the archive name is taken.
Solutions
- Inspect the existing archive directory and remove/rename it if unwanted
- Archive under a different name or remove the conflicting archive, then re-run
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/core/archive.ts:491 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/694a2d2134c40e4c.
Report an issue: GitHub.
Appendix: source
Thrown at src/core/archive.ts:491
*/
class MoveDestinationRetainedError extends Error {}
class RetirementBackupsRetainedError extends Error {}
async function moveDirectory(
src: string,
dest: string,
options: {
verifyCopiedDestination?: (stagedSource: string) => Promise<void>;
} = {}
): Promise<void> {
try {
await fs.rename(src, dest);
} catch (err: any) {
const code = err?.code;
// rename onto a non-empty directory: the destination was taken while the
// archive was running. Same condition the pre-flight check reports.
if (code === 'ENOTEMPTY' || code === 'EEXIST') {
throw new ArchiveBlockedError(
'archive_target_exists',
`Archive '${path.basename(dest)}' already exists.`
);
}
if (code === 'EPERM' || code === 'EXDEV') {
const stagedSource = path.join(path.dirname(src), `.openspec-move-${randomUUID()}`);
try {
await fs.rename(src, stagedSource);
} catch (stageError) {
throw new Error(
`Could not safely stage ${src} before the fallback archive copy ` +
`(${stageError instanceof Error ? stageError.message : String(stageError)}). ` +
'No fallback copy was attempted.'
);
}
let destIsOurs = false;
let stagedFingerprint: string;
try {View on GitHub (pinned to 6926ccb18a)