{"record":{"id":"dc92763d433fede5","repo":"can1357/oh-my-pi","slug":"duplicate-or-conflicting-asar-member-path-membe","errorCode":null,"errorMessage":"Duplicate or conflicting ASAR member path '${memberPath}'","messagePattern":"Duplicate or conflicting ASAR member path '(.+?)'","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/asar.ts","lineNumber":437,"sourceCode":"\t\t\tconst memberPath = writerPath(member[0]);\n\t\t\tconst parts = memberPath.split(\"/\");\n\t\t\tlet directory = root;\n\t\t\tfor (let index = 0; index < parts.length - 1; index++) {\n\t\t\t\tconst part = parts[index]!;\n\t\t\t\tconst existing = directory.files[part];\n\t\t\t\tif (existing && !(\"files\" in existing)) {\n\t\t\t\t\tthrow new ArchiveError(\n\t\t\t\t\t\t`ASAR member path '${memberPath}' crosses file '${parts.slice(0, index + 1).join(\"/\")}'`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (!existing) {\n\t\t\t\t\tdirectory.files[part] = { files: Object.create(null) as Record<string, AsarNode> };\n\t\t\t\t}\n\t\t\t\tdirectory = directory.files[part] as AsarDirectoryNode;\n\t\t\t}\n\t\t\tconst name = parts.at(-1)!;\n\t\t\tif (directory.files[name]) {\n\t\t\t\tthrow new ArchiveError(`Duplicate or conflicting ASAR member path '${memberPath}'`);\n\t\t\t}\n\t\t\tif (!Number.isSafeInteger(member[1].byteLength) || !Number.isSafeInteger(payloadSize + member[1].byteLength)) {\n\t\t\t\tthrow new ArchiveError(\"ASAR payload is too large to encode safely\");\n\t\t\t}\n\t\t\tdirectory.files[name] = { size: member[1].byteLength, offset: String(payloadSize) };\n\t\t\tpayloads.push(member[1]);\n\t\t\tpayloadSize += member[1].byteLength;\n\t\t}\n\n\t\tconst jsonBytes = ASAR_HEADER_ENCODER.encode(JSON.stringify(root));\n\t\tconst paddedJsonSize = alignAsarPayload(jsonBytes.byteLength);\n\t\tconst innerPayloadSize = 4 + paddedJsonSize;\n\t\tconst headerSize = 4 + innerPayloadSize;\n\t\tif (jsonBytes.byteLength > 0xffffffff || headerSize > 0xffffffff) {\n\t\t\tthrow new ArchiveError(\"ASAR header is too large to encode\");\n\t\t}\n\t\tconst dataOffset = ASAR_PICKLE_PREFIX_SIZE + headerSize;\n\t\tconst archiveSize = dataOffset + payloadSize;","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/asar.ts#L419-L455","documentation":"encodeAsar rejects a member whose full path (after normalization) is already present in the tree, whether as an exact duplicate or as a node of the opposite kind (file vs directory). The library requires every member path to be unique so the JSON header stays unambiguous. The thrown message includes the offending memberPath.","triggerScenarios":"Passing the same path twice in the members iterable to encodeAsar/encodeArchive/bytes (e.g. ['a.txt', b1] and ['a.txt', b2]), or a path that was already created as a directory by a longer member, e.g. ['a/b', x] followed by ['a', y].","commonSituations":"Accidentally including a file twice from overlapping glob patterns (e.g. '**/*' plus '*.txt'); concatenating member lists from two archives that share entries; case-insensitive filesystems where 'Readme.md' and 'readme.md' are the same file but produce distinct keys on some platforms.","solutions":["Deduplicate members by normalized path before calling encodeAsar, keeping the last (or intended) entry.","Fix overlapping glob/include patterns so each file is collected exactly once.","If a directory-vs-file conflict is intended, rename one of the paths.","Catch ArchiveError and log the duplicated memberPath to identify which collection step produced the duplicate."],"exampleFix":"// before\nconst members = [...glob('**/*'), ...glob('*.txt')]; // a.txt collected twice\n// after\nconst byPath = new Map(members);\nconst unique = [...byPath.entries()]; // last entry wins","handlingStrategy":"validation","validationCode":"function dedupeMembers(members) {\n  const byPath = new Map();\n  for (const m of members) {\n    const key = m[0].replace(/\\\\/g, '/');\n    if (byPath.has(key)) throw new Error(`duplicate ASAR member '${key}'`);\n    byPath.set(key, m);\n  }\n  return [...byPath.values()];\n}\nconst unique = dedupeMembers(members);","typeGuard":null,"tryCatchPattern":"try {\n  const archive = await encodeAsar(members);\n} catch (err) {\n  if (err instanceof ArchiveError && err.message.includes('Duplicate or conflicting ASAR member')) {\n    console.error(`Duplicate path in member list: ${err.message}`);\n    // fall back to a deduped retry\n    return encodeAsar(dedupeMembers(members));\n  }\n  throw err;\n}","preventionTips":["Deduplicate members by normalized path before every encode call.","Audit glob patterns for overlaps ('**/*' vs '*.txt').","Use case-normalized keys when merging member lists from case-insensitive filesystems.","When merging archives, drop or rename shared entries explicitly."],"tags":["asar","archive","duplicate","validation"],"backgroundTag":"asar-duplicate-entry","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}