{"record":{"id":"eea7b061b0f6b579","repo":"siyuan-note/siyuan","slug":"name-is-required","errorCode":null,"errorMessage":"--name is required","messagePattern":"--name is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/notebook.go","lineNumber":69,"sourceCode":"\t\t}\n\t\tswitch outputFormat {\n\t\tcase \"json\":\n\t\t\tdata, _ := json.MarshalIndent(boxes, \"\", \"  \")\n\t\t\tfmt.Println(string(data))\n\t\tdefault:\n\t\t\tprintNotebookTable(boxes)\n\t\t}\n\t\treturn nil\n\t},\n}\n\nvar notebookCreateCmd = &cobra.Command{\n\tUse:   \"create --name <name>\",\n\tShort: \"Create a notebook\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tname, _ := cmd.Flags().GetString(\"name\")\n\t\tif name == \"\" {\n\t\t\treturn fmt.Errorf(\"--name is required\")\n\t\t}\n\n\t\tif dryRun {\n\t\t\tfmt.Printf(\"[dry-run] Would create notebook \\\"%s\\\"\\n\", name)\n\t\t\treturn nil\n\t\t}\n\n\t\tid, err := model.CreateBox(name)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif _, err = model.Mount(id); err != nil {\n\t\t\treturn fmt.Errorf(\"notebook [%s] was created but could not be opened: %w\", id, err)\n\t\t}\n\t\tmodel.AppendPushReloadFiletreeEntry()\n\t\tfmt.Println(id)\n\t\treturn nil\n\t},","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/notebook.go#L51-L87","documentation":"Thrown by the `notebook create` subcommand when the `--name` flag is empty. The name becomes the notebook's display title. The check runs before the dry-run guard, so it fires in all modes.","triggerScenarios":"Running `siyuan notebook create` with no `--name`, or `--name \"\"`. The RunE reads the flag and returns immediately when it is empty.","commonSituations":"Typing the command without a name; passing an empty variable; assuming a default name is supplied.","solutions":["Supply a name: `siyuan notebook create --name \"My Notebook\"`","Use a non-empty quoted string if the name contains spaces"],"exampleFix":"// before\nsiyuan notebook create\n// after\nsiyuan notebook create --name \"Research\"","handlingStrategy":"validation","validationCode":"name := strings.TrimSpace(rawName)\nif name == \"\" {\n    return errors.New(\"notebook name is required\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass `--name` to `notebook create`","Quote names containing spaces","Avoid relying on a default name"],"tags":["cli","validation","missing-argument","notebook","go","siyuan"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}