{"record":{"id":"9ed5148b28c681f2","repo":"siyuan-note/siyuan","slug":"ids-is-required-9ed514","errorCode":null,"errorMessage":"--ids is required","messagePattern":"--ids is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/block.go","lineNumber":465,"sourceCode":"\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)\n\t\tif len(ids) == 0 {\n\t\t\treturn fmt.Errorf(\"no valid IDs provided\")\n\t\t}\n\t\tinfos := model.GetDocsInfo(ids, false, false)\n\t\tswitch outputFormat {\n\t\tcase \"json\":\n\t\t\tdata, _ := json.MarshalIndent(infos, \"\", \"  \")\n\t\t\tfmt.Println(string(data))\n\t\tdefault:\n\t\t\tw := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)\n\t\t\tfmt.Fprintln(w, \"ID\\tNAME\\tROOTID\\tREFCOUNT\")\n\t\t\tfor _, info := range infos {\n\t\t\t\tfmt.Fprintf(w, \"%s\\t%s\\t%s\\t%d\\n\", info.ID, info.Name, info.RootID, info.RefCount)\n\t\t\t}\n\t\t\tfor _, id := range ids {\n\t\t\t\tfound := false","sourceCodeStart":447,"sourceCodeEnd":483,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/block.go#L447-L483","documentation":"Thrown by the `block batch-get` cobra subcommand when the `--ids` flag is empty or omitted. The command fetches document info for a comma-separated list of block IDs via `model.GetDocsInfo`, so at least one ID is mandatory. It fails fast before any model call to avoid a pointless empty query.","triggerScenarios":"Running `siyuan block batch-get` with no `--ids` flag, or `--ids \"\"` (empty string), or `--ids` pointing to an unset shell variable that expands to nothing.","commonSituations":"Typo in the flag name (`--id` instead of `--ids`), copy-pasting a command template and forgetting to substitute the real IDs, or a shell quoting bug that strips the value.","solutions":["Pass a non-empty comma-separated ID list: `siyuan block batch-get --ids 20240101000000-abc1234,20240101000000-def5678`","Verify the IDs exist with `siyuan block get --id <id>` before batching","Check the flag name spelling — it is `--ids` (plural), not `--id`"],"exampleFix":"// before\nsiyuan block batch-get --ids\n\n// after\nsiyuan block batch-get --ids 20240101000000-abc1234,20240101000000-def5678","handlingStrategy":"validation","validationCode":"idsFlag := \"\" // value to pass as --ids\nif strings.TrimSpace(idsFlag) == \"\" {\n    log.Fatal(\"--ids must be a non-empty comma-separated list\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wrap CLI invocations in a helper that pre-validates required flags before exec","Always quote the --ids value to prevent shell word-splitting","Generate IDs from a trusted source (block get / SQL) rather than hand-typing"],"tags":["cli","block","flag-validation","argument-required"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}