{"record":{"id":"6700354516767330","repo":"can1357/oh-my-pi","slug":"malformed-embedded-docs-index-non-empty-payload-w","errorCode":null,"errorMessage":"Malformed embedded docs index: non-empty payload without a newline separator. Rebuild the binary or bundle.","messagePattern":"Malformed embedded docs index: non-empty payload without a newline separator\\. Rebuild the binary or bundle\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/internal-urls/docs-index.ts","lineNumber":129,"sourceCode":"}\n\n/** Empty index for when no docs corpus is reachable — degrades `omp://` instead of throwing ENOENT at callers. */\nfunction emptyIndex(): DocsIndex {\n\tlogger.warn(\n\t\t\"omp:// docs corpus unavailable: no build-time embed, on-disk docs/ directory, or shipped dist embed found\",\n\t);\n\treturn { filenames: [], getBody: () => Promise.resolve(undefined) };\n}\n\nlet index: DocsIndex | undefined;\nfunction getIndex(): DocsIndex {\n\tif (index !== undefined) return index;\n\t// Populated embed in compiled binaries / npm bundle entrypoint. A non-empty\n\t// payload with no newline is a broken build (truncated/corrupt embed).\n\tif (docsEmbed.length > 0) {\n\t\tconst decoded = decodeDocsIndex(docsEmbed);\n\t\tif (decoded === null) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Malformed embedded docs index: non-empty payload without a newline separator. \" +\n\t\t\t\t\t\"Rebuild the binary or bundle.\",\n\t\t\t);\n\t\t}\n\t\tindex = decoded;\n\t\treturn index;\n\t}\n\t// No build-time embed → running from TypeScript source. Prefer the shipped\n\t// embed file (`dist/docs-index.generated.txt`): it exists only in the packaged\n\t// npm tarball (or a dev tree that ran `gen:bundle`), so it authoritatively\n\t// identifies an installed package and avoids probing the consumer's\n\t// `node_modules/docs`, which `readDocsFromDisk()` would otherwise resolve to\n\t// and where a stray `docs` dir/package could shadow the real corpus. Fall back\n\t// to the on-disk `docs/` corpus for a genuine monorepo checkout, then degrade\n\t// to an empty index so a missing corpus never propagates ENOENT to callers.\n\tindex = readShippedEmbed() ?? readDocsFromDisk() ?? emptyIndex();\n\treturn index;\n}","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/internal-urls/docs-index.ts#L111-L147","documentation":"In compiled binaries and npm bundles the docs index is embedded in the binary itself. A non-empty embed with no newline separator cannot be decoded, so getIndex throws, flagging a broken build (truncated/corrupt embed) rather than silently returning an empty doc list.","triggerScenarios":"First call to getIndex (directly or via getDocFilenames/getEmbeddedDoc) when running a compiled binary or bundled build whose in-binary docsEmbed string is non-empty but malformed.","commonSituations":"A binary produced by a failed/interrupted compile-embed step; patching or post-processing the binary corrupted the embed; mixing an old binary with new reader code.","solutions":["Rebuild the binary/bundle (regenerates the embedded docs index)","Re-download/reinstall the official binary instead of using a locally patched one","Check the build pipeline step that embeds docs ran to completion"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const docs = getDocFilenames()\n} catch (err) {\n  if (String(err).includes('Malformed embedded docs index')) {\n    logger.warn('embedded docs index corrupt; rebuild the binary', {})\n    return []\n  }\n  throw err\n}","preventionTips":["Ensure the embed step completes before shipping binaries","Distribute only official, checksum-verified binaries","Avoid post-processing compiled binaries"],"tags":["docs","corrupt-binary","embed","build"],"backgroundTag":"corrupt-bundle-asset","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}