{"record":{"id":"dec4fddd64b7098d","repo":"siyuan-note/siyuan","slug":"document-block-s-cannot-be-used-as-a-previous-s","errorCode":null,"errorMessage":"document block [%s] cannot be used as a previous sibling; use it as --parent instead","messagePattern":"document block \\[(.+?)\\] cannot be used as a previous sibling; use it as --parent instead","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/block.go","lineNumber":449,"sourceCode":"\t},\n}\n\nfunc validateBlockMove(id, parentID, previousID string) error {\n\tbt := treenode.GetBlockTree(id)\n\tif nil == bt {\n\t\treturn fmt.Errorf(\"block not found: %s\", id)\n\t}\n\tif \"d\" == bt.Type {\n\t\treturn fmt.Errorf(\"document block [%s] cannot be moved with block move; use document move instead\", id)\n\t}\n\n\tif \"\" != previousID {\n\t\tpreviousBt := treenode.GetBlockTree(previousID)\n\t\tif nil == previousBt {\n\t\t\treturn fmt.Errorf(\"previous block not found: %s\", previousID)\n\t\t}\n\t\tif \"d\" == previousBt.Type {\n\t\t\treturn fmt.Errorf(\"document block [%s] cannot be used as a previous sibling; use it as --parent instead\", previousID)\n\t\t}\n\t\treturn nil\n\t}\n\tif err := treenode.CheckListItemNesting(parentID, id); err != nil {\n\t\treturn err\n\t}\n\treturn treenode.CheckContainerParent(parentID)\n}\n\nvar blockBatchGetCmd = &cobra.Command{\n\tUse:   \"batch-get --ids id1,id2,...\",\n\tShort: \"Batch get block info\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tidsStr, _ := cmd.Flags().GetString(\"ids\")\n\t\tif idsStr == \"\" {\n\t\t\treturn fmt.Errorf(\"--ids is required\")\n\t\t}\n\t\tids := splitIDs(idsStr)","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/block.go#L431-L467","documentation":"Thrown inside `validateBlockMove` when `--previous` resolves to a block of type `\"d\"` (document). A document cannot act as a previous sibling of a block move — documents are not siblings of in-document blocks. The error directs the user to make that document the `--parent` instead, which is the structurally correct relationship.","triggerScenarios":"Passing a document root ID as `--previous` (sibling anchor) instead of `--parent` (container). The previous block passes the existence check but its type `d` trips this semantic guard.","commonSituations":"Confusing the destination document's ID as a sibling rather than the parent; copy-pasting a doc ID into `--previous`; building a move script that reused a document ID in the wrong slot.","solutions":["Move the document ID from `--previous` to `--parent`: `siyuan-kernel block move --id <mover> --parent <docID>`","If you truly need sibling positioning, use a non-document block ID for `--previous`","Check the candidate's type with `block get` to confirm it is not type `d`"],"exampleFix":"// before\nsiyuan-kernel block move --id <mover> --parent <dest> --previous <docID>\n// after\nsiyuan-kernel block move --id <mover> --parent <docID>","handlingStrategy":"validation","validationCode":"// A document cannot be a previous sibling; reject or redirect to --parent.\nif previousID != \"\" {\n    pbt := treenode.GetBlockTree(previousID)\n    if pbt == nil {\n        return fmt.Errorf(\"previous sibling %s not found\", previousID)\n    }\n    if pbt.Type == \"d\" {\n        // route the document ID to --parent instead\n        return fmt.Errorf(\"previous %s is a document; pass it as --parent\", previousID)\n    }\n}","typeGuard":"func isDocumentBlock(id string) bool {\n    bt := treenode.GetBlockTree(id)\n    return bt != nil && bt.Type == \"d\"\n}","tryCatchPattern":null,"preventionTips":["Distinguish container/parent slots from sibling slots in your move helper","Inspect the candidate block type before assigning it to `--previous`","When a document ID shows up, automatically redirect it to `--parent` in tooling"],"tags":["cli","block","move","semantic","document","go"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}