{"record":{"id":"502e1bcc94c2390d","repo":"siyuan-note/siyuan","slug":"id-is-required-502e1b","errorCode":null,"errorMessage":"--id is required","messagePattern":"--id is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/block.go","lineNumber":48,"sourceCode":"\t\"github.com/siyuan-note/siyuan/kernel/util\"\n\n\t\"github.com/spf13/cobra\"\n)\n\nvar blockCmd = &cobra.Command{\n\tUse:   \"block\",\n\tShort: \"Block operations\",\n}\n\n// ─── Read ──────────────────────────────────────────────────────────────────────\n\nvar blockGetCmd = &cobra.Command{\n\tUse:   \"get --id <id>\",\n\tShort: \"Get block info\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tid, _ := cmd.Flags().GetString(\"id\")\n\t\tif id == \"\" {\n\t\t\treturn fmt.Errorf(\"--id is required\")\n\t\t}\n\t\tblock, err := model.GetBlock(id, nil)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tswitch outputFormat {\n\t\tcase \"json\":\n\t\t\tdata, _ := json.MarshalIndent(block, \"\", \"  \")\n\t\t\tfmt.Println(string(data))\n\t\tdefault:\n\t\t\tfmt.Printf(\"ID:       %s\\n\", block.ID)\n\t\t\tfmt.Printf(\"Type:     %s\\n\", block.Type)\n\t\t\tfmt.Printf(\"Name:     %s\\n\", block.Name)\n\t\t\tfmt.Printf(\"Box:      %s\\n\", block.Box)\n\t\t\tfmt.Printf(\"HPath:    %s\\n\", block.HPath)\n\t\t\tif block.Content != \"\" {\n\t\t\t\tfmt.Printf(\"Content:  %s\\n\", truncate(block.Content, 200))\n\t\t\t}","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/block.go#L30-L66","documentation":"Thrown by the `block get` subcommand when `--id` is empty. `--id` selects the block to read via `model.GetBlock(id, nil)`. Without it there is no target; the command aborts before touching the model layer.","triggerScenarios":"Running `siyuan-kernel block get` without `--id`, or with `--id \"\"`. The block ID is the SiYuan document/block identifier (format like `20260605100657-v080a4j`).","commonSituations":"Forgetting the flag; passing a positional ID instead of `--id`; copy-paste leaving the placeholder `<id>` empty.","solutions":["Pass a valid block ID: `siyuan-kernel block get --id 20260605100657-v080a4j`","Get the ID from `siyuan-kernel sql` or the editor's block menu first if unknown","Check that the ID was not mangled by shell expansion (IDs contain hyphens)"],"exampleFix":"// before\nsiyuan-kernel block get\n// after\nsiyuan-kernel block get --id 20260605100657-v080a4j","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(blockID) == \"\" {\n    return fmt.Errorf(\"block ID is required for `block get`\")\n}\n// then: siyuan-kernel block get --id <blockID>","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize a `requireBlockID(id)` helper across all scripts","Treat the block ID as a mandatory function parameter, not an optional flag","Fetch IDs programmatically via `sql` rather than hard-coding"],"tags":["cli","block","argument-validation","go"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}