{"record":{"id":"a55cbcc2a40f5a8a","repo":"siyuan-note/siyuan","slug":"get-block-failed-s","errorCode":null,"errorMessage":"get block failed: %s","messagePattern":"get block failed: (.+?)","errorType":"validation","errorClass":null,"httpStatus":200,"severity":"error","filePath":"kernel/api/block_op.go","lineNumber":52,"sourceCode":"func parseBlockUpdateInput(arg map[string]any, ret *gulu.Result) (input model.BlockUpdateInput, ok bool) {\n\tif !util.ParseJsonArgs(arg, ret,\n\t\tutil.BindJsonArg(\"id\", &input.ID, true, true),\n\t\tutil.BindJsonArg(\"data\", &input.Data, true, false),\n\t\tutil.BindJsonArg(\"dataType\", &input.DataType, true, true),\n\t\tutil.BindJsonArg(\"lockType\", &input.LockType, false, false),\n\t) {\n\t\treturn\n\t}\n\tif util.InvalidIDPattern(input.ID, ret) {\n\t\treturn input, false\n\t}\n\treturn input, true\n}\n\nfunc buildUpdatedTaskListItemBlockDOM(id, marker string, luteEngine *lute.Lute) (data string, err error) {\n\tblock, err := model.GetBlock(id, nil)\n\tif err != nil {\n\t\treturn \"\", errors.New(\"get block failed: \" + err.Error())\n\t}\n\n\tif \"NodeListItem\" != block.Type {\n\t\treturn \"\", errors.New(\"block is not a list item\")\n\t}\n\n\ttree, err := filesys.LoadTree(block.Box, block.Path, luteEngine)\n\tif err != nil {\n\t\treturn \"\", errors.New(\"load tree failed: \" + err.Error())\n\t}\n\n\tli := treenode.GetNodeInTree(tree, id)\n\tif li == nil {\n\t\treturn \"\", errors.New(\"block not found\")\n\t}\n\n\tif 3 != li.ListData.Typ {\n\t\treturn \"\", errors.New(\"block is not a task list item\")","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/api/block_op.go#L34-L70","documentation":"First failure mode of buildUpdatedTaskListItemBlockDOM (kernel/api/block_op.go), which backs POST /api/block/updateTaskListItemMarker and its batch variant. The block id passed format validation (InvalidIDPattern) but model.GetBlock failed at the SQL layer; the underlying error text is appended after the prefix, so the real cause (query failure, unavailable/corrupt index) rides along in the message.","triggerScenarios":"Calling /api/block/updateTaskListItemMarker with an id that is well-formed but absent from or broken in the SQL index (siyuan.db); calling while the database is locked by indexing, sync, or another heavy transaction; calling right after workspace corruption or an interrupted reindex.","commonSituations":"Stale block id captured before a rebuild; kernel mid-reindex or sync so the blocks table is inconsistent; siyuan.db corrupted after a crash or bad shutdown; plugin cached ids across workspace switches.","solutions":["Verify the id first with /api/block/getBlockInfo (or getBlockKramdown) to see whether the block is queryable at all","Wait for indexing/sync to quiesce (check the status via the kernel UI/status API) and retry the call","If the block genuinely exists on disk, trigger a rebuild of the content index so the blocks table is repopulated","Inspect the appended underlying error and the kernel log; if siyuan.db is corrupt, restore the workspace from backup or repo snapshot"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const info = await fetchPost('/api/block/getBlockInfo', { id });\nif (info.code !== 0) {\n  throw new Error(`block [${id}] not queryable, skip marker update`);\n}\nawait fetchPost('/api/block/updateTaskListItemMarker', { id, marker });","typeGuard":null,"tryCatchPattern":"try {\n  await updateTaskMarker(id, marker);\n} catch (e) {\n  if (/^get block failed:/.test(e.message)) {\n    const cause = e.message.slice('get block failed:'.length).trim();\n    // index/db level: wait for indexing to settle, verify block exists, then retry once\n  }\n}","preventionTips":["Validate the block is queryable via getBlockInfo before mutating it","Avoid calling block APIs during heavy indexing/sync windows","Log the appended underlying error — it distinguishes missing block from db failure"],"tags":["block","database","index","api","siyuan"],"backgroundTag":"database-query-failed","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}