{"record":{"id":"d7a4a6a434011fe1","repo":"Fission-AI/OpenSpec","slug":"copyerror-instanceof-error-copyerror-message","errorCode":null,"errorMessage":"${copyError instanceof Error ? copyError.message : String(copyError)} Could not restore the staged source at ${stagedSource} (${restoreError instanceof Error ? restoreError.message : String(restoreError)}).","messagePattern":"(.+?) Could not restore the staged source at (.+?) \\((.+?)\\)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/core/archive.ts","lineNumber":523,"sourceCode":"        );\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        }\n        try {\n          await fs.rename(stagedSource, src);\n        } catch (restoreError) {\n          throw new Error(\n            `${copyError instanceof Error ? copyError.message : String(copyError)} ` +\n              `Could not restore the staged source at ${stagedSource} ` +\n              `(${restoreError instanceof Error ? restoreError.message : String(restoreError)}).`\n          );\n        }\n        if ((copyError as NodeJS.ErrnoException).code === 'EEXIST') {\n          throw new ArchiveBlockedError(\n            'archive_target_exists',\n            `Archive '${path.basename(dest)}' already exists.`\n          );\n        }\n        throw copyError;\n      }\n      try {\n        await options.verifyCopiedDestination?.(stagedSource);\n        await assertCopiedDirectoryUnchanged(stagedSource, dest, stagedFingerprint);\n      } catch (verificationError) {\n        await fs.rm(dest, { recursive: true, force: true }).catch(() => undefined);","sourceCodeStart":505,"sourceCodeEnd":541,"githubUrl":"https://github.com/Fission-AI/OpenSpec/blob/6926ccb18afa4ff621112813e9968334576ee11a/src/core/archive.ts#L505-L541","documentation":"Error \"${copyError instanceof Error ? copyError.message : String(copyError)} Could not restore the staged source at ${stagedSource} (${restoreError instanceof Error ? restoreError.message : String(restoreError)}).\" thrown in Fission-AI/OpenSpec.","triggerScenarios":"Thrown at src/core/archive.ts:523 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"}