codex-team/editor.js · error · Error
Could not convert Block. Failed to extract original Block da
Error message
Could not convert Block. Failed to extract original Block data.
What it means
BlockManager.convert first saves the current block to extract its data; if save() returns falsy (tool's save threw or returned nothing), conversion cannot proceed and this error is thrown.
Source
Thrown at src/components/modules/blockManager.ts:838
});
}
/**
* Converts passed Block to the new Tool
* Uses Conversion Config
*
* @param blockToConvert - Block that should be converted
* @param targetToolName - name of the Tool to convert to
* @param blockDataOverrides - optional new Block data overrides
*/
public async convert(blockToConvert: Block, targetToolName: string, blockDataOverrides?: BlockToolData): Promise<Block> {
/**
* At first, we get current Block data
*/
const savedBlock = await blockToConvert.save();
if (!savedBlock) {
throw new Error('Could not convert Block. Failed to extract original Block data.');
}
/**
* Getting a class of the replacing Tool
*/
const replacingTool = this.Editor.Tools.blockTools.get(targetToolName);
if (!replacingTool) {
throw new Error(`Could not convert Block. Tool «${targetToolName}» not found.`);
}
/**
* Using Conversion Config "export" we get a stringified version of the Block data
*/
const exportedData = await blockToConvert.exportDataAsString();
/**
* Clean exported data with replacing sanitizer configView on GitHub (pinned to 5f45dabbe5)
Solutions
- Verify the tool's save() works (check editor.save() output for that block)
- Re-create the problematic block before converting
- Retry after the editor is fully ready (await editor.isReady)
Example fix
// before
await editor.blocks.convert(id, 'header');
// after
await editor.isReady;
const saved = await editor.save();
if (saved.blocks.find(b => b.id === id)) {
await editor.blocks.convert(id, 'header');
} Defensive patterns
Strategy: validation
Validate before calling
await editor.isReady; const saved = await editor.save(); if (saved.blocks.some(b => b.id === id)) { await editor.blocks.convert(id, target); } Type guard
const hasSavedData = (b: BlockAPI | undefined): b is BlockAPI => Boolean(b);
Try / catch
try { await editor.blocks.convert(id, target); } catch (e) { if (e instanceof Error && e.message.includes('Failed to extract')) { /* block in bad state, recreate it */ } throw e; } Prevention
- Test each tool's save() output
- Convert only after editor.isReady
When it happens
Trigger: The source block's tool save() returning undefined/null or throwing internally; a block in a broken/internal state (e.g. unresolved tool) when convert is called.
Common situations: Custom tools with buggy save() methods; blocks created by paste with incomplete data; calling convert on a block still initializing.
Related errors
- Block Tool with type "${newType}" not found
- Conversion from "${blockToConvert.name}" to "${newType}" is
- Could not convert Block. Tool «${targetToolName}» not found.
- Unable to move Block down since it is already the last
- Unable to move Block up since it is already the first
AI-assisted analysis of codex-team/editor.js@5f45dabbe5 (2026-08-27).
Data as JSON: /api/errors/fa228f7b7ef3c778.
Report an issue: GitHub.