{"record":{"id":"6002c77fca716923","repo":"can1357/oh-my-pi","slug":"archive-path-normalizedpath-not-found","errorCode":null,"errorMessage":"Archive path '${normalizedPath}' not found","messagePattern":"Archive path '(.+?)' not found","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/reader.ts","lineNumber":85,"sourceCode":"\t\t\tmtimeMs: entry.mtimeMs,\n\t\t\tmode: entry.mode,\n\t\t};\n\t}\n\n\t/** List one directory's children, sorted case-insensitively by name. */\n\tlistDirectory(subPath?: string): ArchiveDirectoryEntry[] {\n\t\tconst normalizedPath = normalizeArchiveLookupPath(subPath);\n\t\tif (normalizedPath === undefined) {\n\t\t\tthrow new ArchiveError(\"Archive path cannot contain '..'\");\n\t\t}\n\n\t\tconst resolvedPath = normalizedPath\n\t\t\t? resolveArchiveLinkPath(this.#entries, normalizedPath, this.limits.maxLinkDepth)\n\t\t\t: \"\";\n\t\tif (normalizedPath && resolvedPath !== \"\") {\n\t\t\tconst entry = this.#entries.get(resolvedPath);\n\t\t\tif (!entry) {\n\t\t\t\tthrow new ArchiveError(`Archive path '${normalizedPath}' not found`);\n\t\t\t}\n\t\t\tif (!entry.isDirectory) {\n\t\t\t\tthrow new ArchiveError(`Archive path '${normalizedPath}' is not a directory`);\n\t\t\t}\n\t\t}\n\n\t\tconst sourcePrefix = resolvedPath ? `${resolvedPath}/` : \"\";\n\t\tconst children = new Map<string, ArchiveDirectoryEntry>();\n\n\t\tfor (const entry of this.#entries.values()) {\n\t\t\tif (resolvedPath) {\n\t\t\t\tif (!entry.path.startsWith(sourcePrefix) || entry.path === resolvedPath) continue;\n\t\t\t}\n\n\t\t\tconst relativePath = resolvedPath ? entry.path.slice(sourcePrefix.length) : entry.path;\n\t\t\tconst nextSegment = relativePath.split(\"/\")[0];\n\t\t\tif (!nextSegment) continue;\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/reader.ts#L67-L103","documentation":"`listDirectory` resolved the requested path (following symlinks up to maxLinkDepth) but no entry exists under the resolved path in the archive's entry map, so it throws ArchiveError(`Archive path '${normalizedPath}' not found`). The message reports the originally requested path, not the resolved one (packages/utils/src/ar/reader.ts:85).","triggerScenarios":"Calling `reader.listDirectory('missing/dir')` where no entry with that path exists; a symlinked directory whose target is absent (resolveArchiveLinkPath returns non-empty but lookup misses); typo'd or case-mismatched path (lookups are case-sensitive here).","commonSituations":"Hard-coded paths that don't match the actual archive layout; archives where folders only appear as prefixes of file entries and the directory entry itself doesn't exist; path casing differs (README.DOC vs readme.doc); typos in tooling or scripts.","solutions":["List available entries first (`reader.allEntries()` or listDirectory(undefined) for the root) and confirm the exact path/case before calling again.","Normalize the path (strip leading '/', trailing '/') — directories inside archives are matched as stored, e.g. 'sub/dir' with forward slashes.","If the path comes from a symlink, verify the link target exists in the archive; re-create the archive if the target was never added.","Catch ArchiveError with 'not found' and fall back to a root listing or a closest-match search for the user."],"exampleFix":"// before: assuming the dir exists\nreader.listDirectory('src/utils');\n\n// after: verify against actual entries first\nconst entries = reader.allEntries();\nconst wanted = 'src/utils';\nif (!entries.some(e => e.isDirectory && (e.path === wanted || e.path === wanted + '/'))) {\n  throw new Error(`No such directory in archive: ${wanted}`);\n}\nreader.listDirectory(wanted);","handlingStrategy":"validation","validationCode":"// Confirm the directory exists (exact path/case) before listing\nconst entries = reader.allEntries();\nconst wanted = 'src/utils';\nif (!entries.some(e => e.isDirectory && (e.path === wanted || e.path === wanted + '/'))) {\n  throw new Error(`Directory not in archive: ${wanted}`);\n}\nreader.listDirectory(wanted);","typeGuard":"function hasDirectory(entries: { path: string; isDirectory: boolean }[], dir: string): boolean {\n  return entries.some(e => e.isDirectory && (e.path === dir || e.path === dir + '/'));\n}","tryCatchPattern":"try {\n  return reader.listDirectory(dirPath);\n} catch (err) {\n  if (err instanceof ArchiveError && err.message.endsWith(\"not found\")) {\n    logger.warn('Archive directory missing; falling back to root', { dirPath });\n    return reader.listDirectory(); // root listing\n  }\n  throw err;\n}","preventionTips":["Always derive paths from allEntries() output rather than hard-coding them.","Remember lookups are case-sensitive; match stored casing exactly.","Normalize to forward slashes with no leading/trailing separators.","After repacking archives, re-validate any consumers that reference fixed paths."],"tags":["archive","not-found","path"],"backgroundTag":"path-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}