{"record":{"id":"f43c88662159b5d4","repo":"siyuan-note/siyuan","slug":"content-block-with-id-s-not-found-f43c88","errorCode":null,"errorMessage":"Content block with id [%s] not found","messagePattern":"Content block with id \\[(.+?)\\] not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/blockial.go","lineNumber":100,"sourceCode":"\tif \"0\" != timed {\n\t\tt, e := dateparse.ParseIn(timed, time.Now().Location())\n\t\tif nil != e {\n\t\t\treturn e\n\t\t}\n\t\ttimedMills = t.UnixMilli()\n\t}\n\n\tFlushTxQueue()\n\n\tattrs := sql.GetBlockAttrs(id)\n\ttree, err := LoadTreeByBlockID(id)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tnode := treenode.GetNodeInTree(tree, id)\n\tif nil == node {\n\t\treturn fmt.Errorf(Conf.Language(15), id)\n\t}\n\n\tif ast.NodeDocument != node.Type && node.IsContainerBlock() {\n\t\tnode = treenode.FirstLeafBlock(node)\n\t}\n\n\tcontent := sql.NodeStaticContent(node, nil, false, false, false)\n\tcontent = gulu.Str.SubStr(content, 128)\n\tcontent = strings.ReplaceAll(content, editor.Zwsp, \"\")\n\terr = SetCloudBlockReminder(id, content, timedMills)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tattrName := \"custom-reminder-wechat\"\n\tif \"0\" == timed {\n\t\tdelete(attrs, attrName)\n\t\told := node.IALAttr(attrName)","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/model/blockial.go#L82-L118","documentation":"kernel/model/blockial.go:100, from SetBlockReminder (language key 15): the block's document loaded successfully via LoadTreeByBlockID, but treenode.GetNodeInTree found no node with that ID inside it. The reminder operation aborts before any attribute is written. Practically: the ID is stale (block deleted/merged since you learned it) or the block index mapped the ID to a document that no longer contains it.","triggerScenarios":"POST /api/attr/setBlockReminder with an ID from an old query/cached list after the block was deleted or its document restructured; racing with sync deletions; well-formed ID belonging to a block in another document due to index staleness.","commonSituations":"Reminder scripts iterating saved block IDs; schedules computed offline then applied after the user edited/deleted blocks; multi-client sync removing blocks between query and write.","solutions":["Re-resolve the ID immediately before the call: /api/query select id from blocks where id='...'.","If it should exist, rebuild the index (Settings - Search - rebuild index) to fix stale blocktree.db mappings.","Check File - History / recycle bin if the deletion was accidental."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify the block still exists before updating\nconst q = await fetch(\"/api/query\", {\n  method: \"POST\",\n  headers: { \"Content-Type\": \"application/json\" },\n  body: JSON.stringify({ stmt: `select id, type, root_id from blocks where id='${blockID}'` }),\n});\nconst qr = await q.json();\nif (!qr.data?.length) throw new Error(`Block ${blockID} no longer exists`);","typeGuard":"async function reminderTargetExists(id: string): Promise<boolean> {\n  const r = await fetch(\"/api/query\", { method: \"POST\",\n    headers: { \"Content-Type\": \"application/json\" },\n    body: JSON.stringify({ stmt: `select id from blocks where id='${id}'` }) });\n  const j = await r.json();\n  return j.code === 0 && (j.data?.length ?? 0) > 0;\n}","tryCatchPattern":"try {\n  await setBlockReminder(id, timed);\n} catch (e) {\n  if (/Content block with id \\[.*\\] not found/.test(e.message)) {\n    const fresh = await resolveBlockByText(anchorText); // re-discover target\n    if (fresh) await setBlockReminder(fresh, timed);\n  } else throw e;\n}","preventionTips":["Resolve reminder targets in the same transaction window as the write.","Filter stored ID lists against the blocks table before batch scheduling."],"tags":["siyuan","not-found","stale-state","reminder","api"],"backgroundTag":"stale-entity-reference","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}