siyuan-note/siyuan · error

--notebook is required

Error message

--notebook is required

What it means

Thrown by `dailynote create` when the `--notebook` flag is empty. Daily notes are created inside a specific notebook via `model.CreateDailyNote`, which needs a notebook ID. The guard runs before dry-run and model interaction.

Source

Thrown at kernel/cli/cmd/dailynote.go:39

	"github.com/siyuan-note/siyuan/kernel/model"
	"github.com/siyuan-note/siyuan/kernel/util"

	"github.com/spf13/cobra"
)

var dailynoteCmd = &cobra.Command{
	Use:   "dailynote",
	Short: "Daily note (dailynote) operations",
}

var dailynoteCreateCmd = &cobra.Command{
	Use:   "create --notebook <id>",
	Short: "Create today's daily note",
	RunE: func(cmd *cobra.Command, args []string) error {
		notebook, _ := cmd.Flags().GetString("notebook")
		if notebook == "" {
			return fmt.Errorf("--notebook is required")
		}

		if dryRun {
			fmt.Printf("[dry-run] Would create daily note in notebook %s\n", notebook)
			return nil
		}

		p, _, err := model.CreateDailyNote(notebook)
		if err != nil {
			return err
		}

		model.FlushTxQueue()
		model.AppendPushReloadFiletreeEntry()

		id := util.GetTreeID(p)
		fmt.Println(id)
		return nil

View on GitHub (pinned to 251596fc0d)

Solutions

  1. List notebooks first (`siyuan notebook list`) to obtain the notebook ID
  2. Pass the ID: `siyuan dailynote create --notebook 20240101000000-nb12345`
  3. Use `--dry-run` to validate flag wiring before the real call

Example fix

// before
siyuan dailynote create

// after
siyuan dailynote create --notebook 20240101000000-nb12345
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(notebookID) == "" {
    log.Fatal("--notebook is required")
}

Prevention

When it happens

Trigger: Running `siyuan dailynote create` with no `--notebook`, or `--notebook ""`, or referencing an unset notebook ID variable.

Common situations: Not knowing the notebook ID (it is not the notebook name), or copying a command without substituting the placeholder.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/38b5b811a7c97827. Report an issue: GitHub.