{"record":{"id":"318920fcfeca6c80","repo":"Fission-AI/OpenSpec","slug":"could-not-safely-stage-src-before-the-fallback","errorCode":null,"errorMessage":"Could not safely stage ${src} before the fallback archive copy (${stageError instanceof Error ? stageError.message : String(stageError)}). No fallback copy was attempted.","messagePattern":"Could not safely stage (.+?) before the fallback archive copy \\((.+?)\\)\\. No fallback copy was attempted\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/core/archive.ts","lineNumber":501,"sourceCode":"): Promise<void> {\n  try {\n    await fs.rename(src, dest);\n  } catch (err: any) {\n    const code = err?.code;\n    // rename onto a non-empty directory: the destination was taken while the\n    // archive was running. Same condition the pre-flight check reports.\n    if (code === 'ENOTEMPTY' || code === 'EEXIST') {\n      throw new ArchiveBlockedError(\n        'archive_target_exists',\n        `Archive '${path.basename(dest)}' already exists.`\n      );\n    }\n    if (code === 'EPERM' || code === 'EXDEV') {\n      const stagedSource = path.join(path.dirname(src), `.openspec-move-${randomUUID()}`);\n      try {\n        await fs.rename(src, stagedSource);\n      } catch (stageError) {\n        throw new Error(\n          `Could not safely stage ${src} before the fallback archive copy ` +\n            `(${stageError instanceof Error ? stageError.message : String(stageError)}). ` +\n            'No fallback copy was attempted.'\n        );\n      }\n      let destIsOurs = false;\n      let stagedFingerprint: string;\n      try {\n        stagedFingerprint = await fingerprintDirectoryContents(stagedSource);\n        await fs.mkdir(dest, { mode: 0o700 });\n        destIsOurs = true;\n        await copyDirContents(stagedSource, dest);\n        await options.verifyCopiedDestination?.(stagedSource);\n        await assertCopiedDirectoryUnchanged(stagedSource, dest, stagedFingerprint);\n      } catch (copyError) {\n        if (destIsOurs) {\n          await fs.rm(dest, { recursive: true, force: true }).catch(() => undefined);\n        }","sourceCodeStart":483,"sourceCodeEnd":519,"githubUrl":"https://github.com/Fission-AI/OpenSpec/blob/6926ccb18afa4ff621112813e9968334576ee11a/src/core/archive.ts#L483-L519","documentation":"Error \"Could not safely stage ${src} before the fallback archive copy (${stageError instanceof Error ? stageError.message : String(stageError)}). No fallback copy was attempted.\" thrown in Fission-AI/OpenSpec.","triggerScenarios":"Thrown at src/core/archive.ts:501 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"}