{"record":{"id":"295c283e8775c6ee","repo":"siyuan-note/siyuan","slug":"ids-is-required","errorCode":null,"errorMessage":"--ids is required","messagePattern":"--ids is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/attr.go","lineNumber":118,"sourceCode":"\t\t\treturn nil\n\t\t}\n\n\t\tif err := model.SetBlockAttrs(id, nameValues); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmodel.AppendPushReloadFiletreeEntry()\n\t\tfmt.Println(\"ok\")\n\t\treturn nil\n\t},\n}\n\nvar attrBatchGetCmd = &cobra.Command{\n\tUse:   \"batch-get --ids id1,id2,...\",\n\tShort: \"Batch get block attributes\",\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\n\t\tids := strings.Split(idsStr, \",\")\n\t\tfor i := range ids {\n\t\t\tids[i] = strings.TrimSpace(ids[i])\n\t\t}\n\n\t\tattrs := sql.BatchGetBlockAttrs(ids)\n\t\tswitch outputFormat {\n\t\tcase \"json\":\n\t\t\tdata, _ := json.MarshalIndent(attrs, \"\", \"  \")\n\t\t\tfmt.Println(string(data))\n\t\tdefault:\n\t\t\tfor id, a := range attrs {\n\t\t\t\tfmt.Printf(\"\\n[%s]\\n\", id)\n\t\t\t\tprintAttrTable(a)\n\t\t\t}\n\t\t}","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/attr.go#L100-L136","documentation":"The `attr batch-get` subcommand reads attributes for multiple blocks from a single comma-separated `--ids` flag. If the flag is absent or empty, the handler returns this error before splitting the list. It is a plain required-flag guard.","triggerScenarios":"`siyuan-kernel attr batch-get` with no flags; `--ids ''` after a variable expansion produced nothing; using positional arguments instead of --ids.","commonSituations":"Scripting a batch lookup where the id list variable is empty because an upstream query returned nothing; mistyping the flag as --id (singular, as used by other subcommands).","solutions":["Pass the ids flag: `siyuan-kernel attr batch-get --ids id1,id2`","Note the flag is plural `--ids` (this subcommand) versus `--id` used by get/children/dom etc.","In scripts, abort when the computed id list is empty instead of invoking the command"],"exampleFix":"// before\nsiyuan-kernel attr batch-get --id 20260605100657-v080a4j\n// after\nsiyuan-kernel attr batch-get --ids 20260605100657-v080a4j,20260605100658-x1b2c3d","handlingStrategy":"validation","validationCode":"if [ -z \"$IDS\" ]; then echo \"--ids is required\" >&2; exit 1; fi\nsiyuan-kernel attr batch-get --ids \"$IDS\"","typeGuard":"function hasIdList(args) { return typeof args.ids === \"string\" && args.ids.trim().length > 0; }","tryCatchPattern":"if err := cmd.Execute(); err != nil && strings.Contains(err.Error(), \"--ids is required\") { // cmd.Usage() }","preventionTips":["This subcommand uses plural --ids (comma-separated), unlike sibling --id flags","Check the source of the id list — an empty upstream result is the usual cause","Trim ids when building the list; the command trims each entry itself"],"tags":["cli","required-flag","argument-validation"],"backgroundTag":"missing-required-flag","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"}