{"record":{"id":"3b6b9591a44f3b90","repo":"can1357/oh-my-pi","slug":"conversion-failed-details","errorCode":null,"errorMessage":"Conversion failed:\n${details}","messagePattern":"Conversion failed:\n(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/markit/registry.ts","lineNumber":55,"sourceCode":"\t\t\tfilename: path.basename(filePath),\n\t\t\t...extra,\n\t\t};\n\t\treturn this.convert(buffer, streamInfo);\n\t}\n\n\tasync convert(input: Buffer, streamInfo: StreamInfo): Promise<ConversionResult> {\n\t\tconst errors: { converter: string; error: Error }[] = [];\n\t\tfor (const converter of this.#converters) {\n\t\t\tif (!converter.accepts(streamInfo)) continue;\n\t\t\ttry {\n\t\t\t\treturn await converter.convert(input, streamInfo, this.#options);\n\t\t\t} catch (err) {\n\t\t\t\terrors.push({ converter: converter.name, error: err instanceof Error ? err : new Error(String(err)) });\n\t\t\t}\n\t\t}\n\t\tif (errors.length > 0) {\n\t\t\tconst details = errors.map(e => `  ${e.converter}: ${e.error.message}`).join(\"\\n\");\n\t\t\tthrow new Error(`Conversion failed:\\n${details}`);\n\t\t}\n\t\tthrow new Error(`Unsupported format: ${streamInfo.extension || streamInfo.mimetype || \"unknown\"}`);\n\t}\n}\n","sourceCodeStart":37,"sourceCodeEnd":60,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/markit/registry.ts#L37-L60","documentation":"Markit.convert tries every registered converter that accepts the stream; if at least one candidate ran but all failed, it aggregates their errors and throws a single 'Conversion failed:' error listing '<converter>: <message>' per line. It signals the format was recognized but every applicable converter rejected or crashed on the content.","triggerScenarios":"Calling convert/convertFile on a stream whose extension/mimetype matches one or more converters, but each converter's convert() threw (corrupt document, parser exception, encrypted/DRM file, password-protected PDF, etc.).","commonSituations":"Encrypted or password-protected PDF; malformed docx/epub produced by buggy generators; empty or truncated file passed with a recognized extension; parser library incompatibility.","solutions":["Read the per-converter messages after 'Conversion failed:' — they name the root cause for each converter.","Fix the underlying document (repair, decrypt, or re-export it) based on those messages.","Verify the file is complete and non-empty; re-download or re-export.","If no converter matched at all, the registry instead reports 'Unsupported format' — check extension/mimetype routing."],"exampleFix":"// caller-side handling\ntry {\n  const result = await markit.convertFile(\"protected.pdf\");\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"Conversion failed:\")) {\n    // inspect per-converter detail lines, e.g. decrypt the PDF first\n  }\n  throw err;\n}","handlingStrategy":"try-catch","validationCode":"import * as fs from \"node:fs\";\nfunction fileLooksReadable(path: string): boolean {\n  const st = fs.statSync(path);\n  return st.isFile() && st.size > 0;\n}","typeGuard":"function isConversionFailedError(err: unknown): err is Error & { message: string } {\n  return err instanceof Error && err.message.startsWith(\"Conversion failed:\\n\");\n}","tryCatchPattern":"try {\n  const result = await markit.convertFile(\"doc.pdf\");\n} catch (err) {\n  if (isConversionFailedError(err)) {\n    const perConverter = err.message.split(\"\\n\").slice(1); // ['  Pdf: ...', ...]\n    console.error(perConverter);\n  }\n  throw err;\n}","preventionTips":["Decrypt/remove passwords from documents before conversion.","Repair or re-export corrupt documents at the source.","Verify file size/checksum after downloads.","Keep converter dependencies up to date."],"tags":["conversion","document-processing","aggregated-errors","markitdown"],"backgroundTag":"document-conversion-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}