{"record":{"id":"113ed837ba4a7e92","repo":"siyuan-note/siyuan","slug":"id-is-required-113ed8","errorCode":null,"errorMessage":"--id is required","messagePattern":"--id is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/document.go","lineNumber":117,"sourceCode":"\t\tfmt.Println(id)\n\t\treturn nil\n\t},\n}\n\nfunc normalizeDocumentCreateParentPath(parentPath string) string {\n\tif \"\" == parentPath {\n\t\treturn \"/\"\n\t}\n\treturn strings.TrimSuffix(path.Clean(parentPath), \".sy\")\n}\n\nvar documentGetCmd = &cobra.Command{\n\tUse:   \"get --id <id>\",\n\tShort: \"Get document 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\tbt := treenode.GetBlockTree(id)\n\t\tif bt == nil {\n\t\t\treturn fmt.Errorf(\"document not found: %s\", id)\n\t\t}\n\n\t\ttree, err := model.LoadTreeByBlockID(id)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tblock, err := model.GetBlock(id, tree)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tswitch outputFormat {\n\t\tcase \"json\":\n\t\t\tdata, _ := json.MarshalIndent(block, \"\", \"  \")","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/document.go#L99-L135","documentation":"The `siyuan document get` command requires the document (block) ID via `--id`. RunE rejects an empty id before calling treenode.GetBlockTree. This is a presence check only; a syntactically valid but unknown ID produces the separate \"document not found\" error instead.","triggerScenarios":"Running `siyuan document get` without `--id <id>` or with an empty value. Unknown flag names (e.g. `--doc`) also yield \"\" and thus this error.","commonSituations":"Copy-pasting the usage line `get --id <id>` literally instead of substituting a real ID; scripts where the DOC_ID variable is empty because a previous list command output was not captured; flag typo.","solutions":["Pass the document/block ID: `siyuan document get --id 20240101120000-abcdefgh`","Get a valid ID from `siyuan document list --notebook <notebookID>` first","Check the flag spelling and that the variable holding the ID is populated"],"exampleFix":"// before\nsiyuan document get\n// after\nsiyuan document get --id 20240101120000-abcdefgh","handlingStrategy":"validation","validationCode":"[ -n \"$DOC_ID\" ] || { echo \"--id is required\" >&2; exit 1; }\nsiyuan document get --id \"$DOC_ID\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Substitute real IDs into copied usage examples, not the `<id>` placeholder","Capture IDs from document list output into variables immediately","Verify flag name spelling (--id, not --doc or --block)"],"tags":["cli","validation","document","missing-flag"],"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"}