{"record":{"id":"cdc7d1796e7b3a1a","repo":"siyuan-note/siyuan","slug":"id-is-required-cdc7d1","errorCode":null,"errorMessage":"--id is required","messagePattern":"--id is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/notebook.go","lineNumber":106,"sourceCode":"}\n\nfunc formatNotebookWriteError(boxID string, err error) error {\n\tif errors.Is(err, model.ErrBoxClosed) {\n\t\treturn fmt.Errorf(\"notebook [%s] is closed; run `notebook open --id %s` first\", boxID, boxID)\n\t}\n\tif errors.Is(err, model.ErrBoxNotFound) {\n\t\treturn fmt.Errorf(\"notebook [%s] not found\", boxID)\n\t}\n\treturn err\n}\n\nvar notebookRemoveCmd = &cobra.Command{\n\tUse:   \"remove --id <id>\",\n\tShort: \"Remove a notebook\",\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\n\t\tif dryRun {\n\t\t\tfmt.Printf(\"[dry-run] Would remove notebook %s\\n\", id)\n\t\t\treturn nil\n\t\t}\n\n\t\tif err := model.RemoveBox(id); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmodel.AppendPushReloadFiletreeEntry()\n\t\tfmt.Println(id)\n\t\treturn nil\n\t},\n}\n\nvar notebookRenameCmd = &cobra.Command{\n\tUse:   \"rename --id <id> --name <name>\",","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/notebook.go#L88-L124","documentation":"Returned by the `notebook remove` subcommand when the --id flag is empty. The RunE handler reads the flag and aborts before touching any model state, because removal requires a target identifier.","triggerScenarios":"Invoking `notebook remove` with no --id flag, or with `--id \"\"` (empty string). cmd.Flags().GetString(\"id\") returns \"\".","commonSituations":"Typing the command without arguments expecting a positional ID, assuming a default/selected notebook, or a wrapper script that fails to substitute the ID variable.","solutions":["Pass an explicit --id with a valid notebook ID: `notebook remove --id <id>`.","If scripting, ensure the ID variable is non-empty before invoking the command.","Run `notebook list` first to obtain a valid ID."],"exampleFix":"# before\nsiyuan notebook remove\n# after\nsiyuan notebook remove --id 202405121200-realid","handlingStrategy":"validation","validationCode":"# shell: assert before invoking\nif [ -z \"$NB_ID\" ]; then echo \"NB_ID is empty\"; exit 1; fi\nsiyuan notebook remove --id \"$NB_ID\"","typeGuard":"n/a (CLI flag validation)","tryCatchPattern":"n/a (command aborts before any side effect; no partial state to recover)","preventionTips":["Treat required flags as build inputs: validate them in your wrapper script before calling the CLI.","Use `notebook list` to source valid IDs programmatically."],"tags":["cli","notebook","validation","missing-argument"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}