{"record":{"id":"473efb41ac6e1b13","repo":"Fission-AI/OpenSpec","slug":"expected-a-directory-while-verifying-dir","errorCode":null,"errorMessage":"Expected a directory while verifying ${dir}.","messagePattern":"Expected a directory while verifying (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/core/archive.ts","lineNumber":400,"sourceCode":"    const lengths = Buffer.allocUnsafe(16);\n    lengths.writeBigUInt64BE(BigInt(labelBuffer.length), 0);\n    lengths.writeBigUInt64BE(BigInt(valueBuffer.length), 8);\n    hash.update(lengths);\n    hash.update(labelBuffer);\n    hash.update(valueBuffer);\n  };\n  const fingerprintFile = async (filePath: string): Promise<Buffer> => {\n    const fileHash = createHash('sha256');\n    for await (const chunk of createReadStream(filePath)) {\n      fileHash.update(chunk);\n    }\n    return fileHash.digest();\n  };\n\n  const visit = async (dir: string, relativeDir: string): Promise<void> => {\n    const before = await fs.lstat(dir, { bigint: true });\n    if (!before.isDirectory()) {\n      throw new Error(`Expected a directory while verifying ${dir}.`);\n    }\n    updateHashField('directory-mode', (before.mode & 0o7777n).toString());\n    const entries = (await fs.readdir(dir, { withFileTypes: true })).sort((a, b) =>\n      a.name < b.name ? -1 : a.name > b.name ? 1 : 0\n    );\n\n    for (const entry of entries) {\n      const entryPath = path.join(dir, entry.name);\n      const relativePath = path.join(relativeDir, entry.name);\n      const stat = await fs.lstat(entryPath, { bigint: true });\n      updateHashField('path', relativePath);\n\n      if (stat.isDirectory()) {\n        updateHashField('type', 'directory');\n        await visit(entryPath, relativePath);\n      } else if (stat.isSymbolicLink()) {\n        const target = await fs.readlink(entryPath);\n        const after = await fs.lstat(entryPath, { bigint: true });","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/Fission-AI/OpenSpec/blob/6926ccb18afa4ff621112813e9968334576ee11a/src/core/archive.ts#L382-L418","documentation":"Error \"Expected a directory while verifying ${dir}.\" thrown in Fission-AI/OpenSpec.","triggerScenarios":"Thrown at src/core/archive.ts:400 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"}