{"record":{"id":"f19d00c3a0c566c5","repo":"codex-team/editor.js","slug":"block-with-id-id-not-found","errorCode":null,"errorMessage":"Block with id \"${id}\" not found","messagePattern":"Block with id \"(.+?)\" not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/components/modules/api/blocks.ts","lineNumber":332,"sourceCode":"  public insertNewBlock(): void {\n    _.log('Method blocks.insertNewBlock() is deprecated and it will be removed in the next major release. ' +\n      'Use blocks.insert() instead.', 'warn');\n    this.insert();\n  }\n\n  /**\n   * Updates block data by id\n   *\n   * @param id - id of the block to update\n   * @param data - (optional) the new data\n   * @param tunes - (optional) tune data\n   */\n  public update = async (id: string, data?: Partial<BlockToolData>, tunes?: {[name: string]: BlockTuneData}): Promise<BlockAPIInterface> => {\n    const { BlockManager } = this.Editor;\n    const block = BlockManager.getBlockById(id);\n\n    if (block === undefined) {\n      throw new Error(`Block with id \"${id}\" not found`);\n    }\n\n    const updatedBlock = await BlockManager.update(block, data, tunes);\n\n    // we cast to any because our BlockAPI has no \"new\" signature\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    return new (BlockAPI as any)(updatedBlock);\n  };\n\n  /**\n   * Converts block to another type. Both blocks should provide the conversionConfig.\n   *\n   * @param id - id of the existing block to convert. Should provide 'conversionConfig.export' method\n   * @param newType - new block type. Should provide 'conversionConfig.import' method\n   * @param dataOverrides - optional data overrides for the new block\n   * @throws Error if conversion is not possible\n   */\n  private convert = async (id: string, newType: string, dataOverrides?: BlockToolData): Promise<BlockAPIInterface> => {","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/codex-team/editor.js/blob/5f45dabbe5690b7033b2f9047d3985add5045fdd/src/components/modules/api/blocks.ts#L314-L350","documentation":"editor.blocks.update(id, data, tunes) looks the block up by id via BlockManager.getBlockById; if no block with that id exists (removed, stale id from an earlier save, typo) it throws with the offending id.","triggerScenarios":"Calling blocks.update() with an id from an old saved document after re-render; using an id captured before the block was deleted; passing a block id from a different editor instance.","commonSituations":"Async flows that hold a BlockAPI id across a render() or clear() that rebuilt blocks; collaborating/multi-user editing where another user removed the block.","solutions":["Re-fetch fresh ids after any render/structural change before calling update","Check existence first: editor.blocks.getById(id) and skip if null","Wrap in try/catch and refetch the block list on failure"],"exampleFix":"// before\nawait editor.blocks.update(staleId, { text: 'hi' });\n// after\nconst block = editor.blocks.getById(staleId);\nif (block) {\n  await editor.blocks.update(staleId, { text: 'hi' });\n}","handlingStrategy":"type-guard","validationCode":"const block = editor.blocks.getById(id); if (!block) throw new Error(`stale id ${id}`); await editor.blocks.update(id, data);","typeGuard":"const blockExists = (editor: EditorJS, id: string): boolean => editor.blocks.getById(id) !== null;","tryCatchPattern":"try { await editor.blocks.update(id, data); } catch (e) { if (e instanceof Error && e.message.includes('not found')) { /* refetch ids and retry once */ } throw e; }","preventionTips":["Re-fetch ids after render()/clear()","Never persist block ids across sessions expecting them to survive"],"tags":["block-id","update","not-found","editorjs"],"backgroundTag":"entity-not-found","analyzedSha":"5f45dabbe5690b7033b2f9047d3985add5045fdd","analyzedAt":"2026-08-27T22:50:23.124Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}