{"record":{"id":"c3ab4886971fcace","repo":"siyuan-note/siyuan","slug":"id-is-required-c3ab48","errorCode":null,"errorMessage":"--id is required","messagePattern":"--id is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/outline.go","lineNumber":40,"sourceCode":"\t\"strings\"\n\n\t\"github.com/siyuan-note/siyuan/kernel/model\"\n\n\t\"github.com/spf13/cobra\"\n)\n\nvar outlineCmd = &cobra.Command{\n\tUse:   \"outline\",\n\tShort: \"Document outline (heading tree)\",\n}\n\nvar outlineGetCmd = &cobra.Command{\n\tUse:   \"get --id <id>\",\n\tShort: \"Get document outline\",\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\tpaths, err := model.Outline(id, false)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif len(paths) == 0 {\n\t\t\treturn fmt.Errorf(\"document not found or has no headings\")\n\t\t}\n\t\tswitch outputFormat {\n\t\tcase \"json\":\n\t\t\tdata, _ := json.MarshalIndent(paths, \"\", \"  \")\n\t\t\tfmt.Println(string(data))\n\t\tdefault:\n\t\t\tvar sb strings.Builder\n\t\t\tsb.WriteString(fmt.Sprintf(\"Document outline (%d headings):\\n\\n\", countOutlineHeadings(paths)))\n\t\t\tfor _, p := range paths {\n\t\t\t\twriteOutlinePath(&sb, p, 0)\n\t\t\t}","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/outline.go#L22-L58","documentation":"Returned by the `outline get` subcommand when --id is empty. The document outline command requires a target document/block ID to build its heading tree.","triggerScenarios":"Running `outline get` with no --id flag or an empty value, before model.Outline is called.","commonSituations":"Forgetting the flag, assuming a default document, or a script that failed to resolve the document ID.","solutions":["Pass a valid document ID: `outline get --id <doc-id>`.","Obtain the ID from the editor URL or `block` commands if unsure."],"exampleFix":"# before\nsiyuan outline get\n# after\nsiyuan outline get --id 202406011200-abcdef","handlingStrategy":"validation","validationCode":"[ -n \"$DOC_ID\" ] || { echo 'outline get requires --id'; exit 1; }\nsiyuan outline get --id \"$DOC_ID\"","typeGuard":"n/a (CLI flag validation)","tryCatchPattern":"n/a","preventionTips":["Use a document root ID, not a child block ID, for outline queries.","Source IDs from the editor URL or block inspection commands."],"tags":["cli","outline","validation","missing-argument"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}