{"record":{"id":"845a1be9c204379e","repo":"siyuan-note/siyuan","slug":"task-list-item-marker-length-should-be-1","errorCode":null,"errorMessage":"task list item marker length should be 1","messagePattern":"task list item marker length should be 1","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/api/block_op.go","lineNumber":74,"sourceCode":"\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\")\n\t}\n\n\tif 1 != len(marker) {\n\t\treturn \"\", errors.New(\"task list item marker length should be 1\")\n\t}\n\n\tliMarker := marker[0]\n\tif '[' == liMarker || ']' == liMarker {\n\t\treturn \"\", errors.New(\"task list item marker can not be [ or ]\")\n\t}\n\n\tmarkerNode := li.ChildByType(ast.NodeTaskListItemMarker)\n\tif nil == markerNode {\n\t\treturn \"\", errors.New(\"task list item marker not found\")\n\t}\n\n\tmarkerNode.TaskListItemMarker = liMarker\n\tmarkerNode.TaskListItemChecked = ' ' != markerNode.TaskListItemMarker\n\n\ttreenode.RefreshUpdated(li)\n\n\treturn luteEngine.RenderNodeBlockDOM(li), nil","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/api/block_op.go#L56-L92","documentation":"Returned by buildUpdatedTaskListItemMarker when the `marker` argument to the /api/block/updateTaskListItemMarker endpoint is not exactly one character long. The kernel updates a task-list-item checkbox by replacing its single status glyph, so any other length (empty string, multi-char like \"[x]\", \"xx\") is rejected before the tree is mutated.","triggerScenarios":"Calling POST /api/block/updateTaskListItemMarker with {\"id\":\"<task-item-id>\", \"marker\":\"\"} or {\"marker\":\"[x]\"} or {\"marker\":\"done\"}. The endpoint (kernel/api/block_op.go:95 updateTaskListItemMarker) parses `marker` from JSON and passes it to buildUpdatedTaskListItemBlockDOM (block_op.go:49), which asserts `len(marker)==1` at line 73.","commonSituations":"Plugin or automation code that sends the GFM task syntax `[ ]`/`[x]` as the marker instead of the bare status character. UI code that clears the field or passes the full checkbox text. Migrating from an API that accepted `[x]` to this one that expects `x`, ` `, or a custom glyph.","solutions":["Send a single character for `marker`: a space ' ' to uncheck, 'x' to check, or another non-bracket glyph.","If your data is in GFM form like '[x]', strip the brackets before calling: marker = raw[1:2].","Confirm the target block is a task list item first (ListData.Typ==3) to avoid the earlier 'block is not a task list item' error."],"exampleFix":"// before\nfetchPost('/api/block/updateTaskListItemMarker', { id, marker: '[x]' })\n// after\nfetchPost('/api/block/updateTaskListItemMarker', { id, marker: 'x' })","handlingStrategy":"validation","validationCode":"// Validate marker is exactly one char before calling the API\nfunction validTaskMarker(m) {\n  return typeof m === 'string' && m.length === 1 && m !== '[' && m !== ']';\n}\nif (!validTaskMarker(marker)) { throw new Error('marker must be a single non-bracket char'); }","typeGuard":"function isTaskMarker(m: unknown): m is string {\n  return typeof m === 'string' && m.length === 1 && m !== '[' && m !== ']';\n}","tryCatchPattern":"try {\n  await fetchPost('/api/block/updateTaskListItemMarker', { id, marker });\n} catch (e) {\n  if (/marker length should be 1/.test(e.msg)) { /* fix marker to single char, retry */ }\n  else { throw e; }\n}","preventionTips":["Normalize GFM tokens '[x]'/'[ ]' to the inner char before sending (index 1).","Whitelist allowed status glyphs (' ', 'x', 'X') in a shared constant.","Confirm the target id is a task list item (ListData.Typ==3) before toggling."],"tags":["api","task-list","validation","kernel"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}