{"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":465,"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":447,"sourceCodeEnd":483,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/block.go#L447-L483","documentation":"A document block ('d' type) was supplied as --previousID (previous sibling) in a block move. Documents cannot serve as siblings in the block tree; to place a block inside or after a document you must reference the document as the parent via --parent instead. Raised in validateBlockMove at kernel/cli/cmd/block.go:465.","triggerScenarios":"Running a block move command with --previous <docID> where the ID resolves to a block tree node with Type \"d\". Typically happens when scripting moves that append content after a document.","commonSituations":"Trying to insert a block at the end of a document by passing the doc ID as previous sibling; confusing root/document IDs with the ID of the last child block; generating move scripts from doc-tree listings instead of block listings.","solutions":["Pass the document ID as --parent instead of --previous so the block is placed within that document","If you need the block after a specific existing block, use the ID of that inner block (not the doc ID) as --previous","Query the document's child blocks first and pick the actual last block ID as the previous sibling"],"exampleFix":"// before\nsiyuan block move --id 20240101120000-block1 --previous 20240101120000-document\n// after\nsiyuan block move --id 20240101120000-block1 --parent 20240101120000-document","handlingStrategy":"validation","validationCode":"type=$(siyuan block batch-get --ids \"$PREVIOUS_ID\" | jq -r '.[0].type // empty')\nif [ \"$type\" = \"d\" ]; then\n  exec siyuan block move --id \"$ID\" --parent \"$PREVIOUS_ID\"\nfi","typeGuard":"function isDocumentBlock(info) { return info && info.type === 'd'; }","tryCatchPattern":null,"preventionTips":["Check the type of any --previous target; documents must be used as --parent","When appending to a document, resolve its last child block and use that as --previous","Never feed doc-tree listings directly into move scripts without type filtering"],"tags":["cli","block-move","document-block","invalid-argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}