{"record":{"id":"0c2eca8d7f89ece1","repo":"siyuan-note/siyuan","slug":"notebook-is-required-0c2eca","errorCode":null,"errorMessage":"--notebook is required","messagePattern":"--notebook is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/import.go","lineNumber":45,"sourceCode":"\nvar importCmd = &cobra.Command{\n\tUse:   \"import\",\n\tShort: \"Import files\",\n}\n\nvar importMdCmd = &cobra.Command{\n\tUse:   \"md --file <path> --notebook <id>\",\n\tShort: \"Import Markdown file or directory\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tfilePath, _ := cmd.Flags().GetString(\"file\")\n\t\tnotebook, _ := cmd.Flags().GetString(\"notebook\")\n\t\ttoPath, _ := cmd.Flags().GetString(\"path\")\n\t\thpath, _ := cmd.Flags().GetString(\"hpath\")\n\t\tif filePath == \"\" {\n\t\t\treturn fmt.Errorf(\"--file is required\")\n\t\t}\n\t\tif notebook == \"\" {\n\t\t\treturn fmt.Errorf(\"--notebook is required\")\n\t\t}\n\n\t\tabsPath, err := filepath.Abs(filePath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif dryRun {\n\t\t\tfmt.Printf(\"[dry-run] Would import Markdown from \\\"%s\\\" to notebook %s\\n\", filePath, notebook)\n\t\t\treturn nil\n\t\t}\n\n\t\tif err := model.ImportFromLocalPath(notebook, absPath, resolvePath(notebook, toPath, hpath)); err != nil {\n\t\t\treturn formatNotebookWriteError(notebook, err)\n\t\t}\n\t\tmodel.AppendPushReloadFiletreeEntry()\n\t\tfmt.Println(\"ok\")\n\t\treturn nil","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/import.go#L27-L63","documentation":"Thrown by the `import md` subcommand when `--notebook` is empty. The notebook ID selects the destination box for the imported Markdown. The check runs after `--file`, so both flags must be supplied.","triggerScenarios":"Running `siyuan import md --file ./notes.md` with no `--notebook`. The RunE reads the notebook flag and returns the error before resolving the file path.","commonSituations":"Forgetting the destination notebook; using a notebook name instead of its ID; an unset env var holding the ID.","solutions":["Find notebook IDs with `siyuan notebook list`","Pass the ID: `siyuan import md --file ./notes.md --notebook <id>`"],"exampleFix":"// before\nsiyuan import md --file ./notes.md\n// after\nsiyuan import md --file ./notes.md --notebook 20240101120000-abc","handlingStrategy":"validation","validationCode":"if notebook == \"\" {\n    out, _ := cmd.Output(\"siyuan\", \"notebook\", \"list\")\n    log.Fatalf(\"notebook ID required. Available:\\n%s\", out)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve notebook IDs via `notebook list`","Pass the ID (not the name) to `--notebook`","Pair `--file` and `--notebook` in import commands"],"tags":["cli","validation","missing-argument","import","notebook","go","siyuan"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}