{"record":{"id":"9dec1883f1a397c5","repo":"siyuan-note/siyuan","slug":"document-not-found-or-has-no-headings","errorCode":null,"errorMessage":"document not found or has no headings","messagePattern":"document not found or has no headings","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/outline.go","lineNumber":47,"sourceCode":"var 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}\n\t\t\tfmt.Print(sb.String())\n\t\t}\n\t\treturn nil\n\t},\n}\n\nfunc countOutlineHeadings(paths []*model.Path) int {","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/outline.go#L29-L65","documentation":"Result-empty guard in outlineGet: model.Outline succeeded but returned no heading paths, which means the given document ID either does not resolve to an existing document or the document contains no headings at all. Not an argument error — check the document ID and its content.","triggerScenarios":"Passing a nonexistent document id, a document with zero headings, or a closed/unloaded document so the outline index returns nothing.","commonSituations":"Wrong workspace, document id vs notebook id confusion, or genuinely heading-less documents.","solutions":["Verify the document exists and the id is a block/document id, not a notebook id","Add at least one heading to the document if it is empty of headings","Ensure the notebook is open so the document is indexed","Confirm the workspace matches where the document lives"],"exampleFix":"// before\nsiyuan outline get --id <id-of-notebook>\n// after\nsiyuan outline get --id 20240101120000-docid12","handlingStrategy":"fallback","validationCode":"siyuan outline get --id \"$DOC_ID\" || { echo \"document missing or has no headings\"; }","typeGuard":"const outlineOk = (paths) => Array.isArray(paths) && paths.length > 0;","tryCatchPattern":"try { run(`siyuan outline get --id ${docId}`); } catch (e) { if (/no headings/.test(e.message)) console.warn(\"Doc has no headings; skipping outline\"); }","preventionTips":["Confirm the id is a document/block id in an open notebook","Ensure documents have at least one heading before outline queries","Keep notebooks open so they are indexed"],"tags":["cli","not-found","outline"],"backgroundTag":"entity-not-found","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"}