{"record":{"id":"a0d7fef59537b49d","repo":"siyuan-note/siyuan","slug":"no-valid-ids-provided","errorCode":null,"errorMessage":"no valid IDs provided","messagePattern":"no valid IDs provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/block.go","lineNumber":469,"sourceCode":"\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\n\t\t\t\tfor _, info := range infos {\n\t\t\t\t\tif info.ID == id {\n\t\t\t\t\t\tfound = true\n\t\t\t\t\t\tbreak","sourceCodeStart":451,"sourceCodeEnd":487,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/block.go#L451-L487","documentation":"Thrown by `block batch-get` when the `--ids` string is non-empty but `splitIDs` (block.go:532) yields zero valid tokens. `splitIDs` splits on commas, trims whitespace, and drops empty parts — so input like `\",\"`, `\" , , \"`, or `\"   \"` produces an empty slice. This is a second-level guard catching malformed but non-empty input.","triggerScenarios":"Passing `--ids ,,,`, `--ids \" \"`, or `--ids \" , , , \"` — strings that are not literally empty but contain only separators/whitespace.","commonSituations":"Trailing-comma lists from a script (`\"id1,id2,\"` is fine, but `\",\"` is not), trailing-comma lists, or copy-paste artifacts that leave only punctuation.","solutions":["Inspect the exact `--ids` value the shell receives; ensure at least one real ID token survives splitting","Build the ID list programmatically and filter empties before passing: join only non-empty values","Quote the argument properly so stray spaces/commas are not introduced"],"exampleFix":"// before\nsiyuan block batch-get --ids \",,\"\n\n// after\nsiyuan block batch-get --ids 20240101000000-abc1234","handlingStrategy":"validation","validationCode":"parts := strings.Split(idsFlag, \",\")\nvalid := []string{}\nfor _, p := range parts {\n    if t := strings.TrimSpace(p); t != \"\" {\n        valid = append(valid, t)\n    }\n}\nif len(valid) == 0 {\n    log.Fatal(\"--ids produced no valid IDs after trimming\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter empties when building the ID list in your script before joining","Avoid trailing commas in generated lists","Unit-test list assembly against edge inputs like \",,\" and \"   \""],"tags":["cli","block","flag-validation","empty-input"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}