siyuan-note/siyuan · error

--av is required

Error message

--av is required

What it means

Thrown by `database get` when the `--av` flag (attribute-view/database ID) is empty. The command loads an AttributeView via `model.GetAttributeView(avID)` and prints metadata; without an ID there is nothing to fetch.

Source

Thrown at kernel/cli/cmd/database.go:61

	RunE: func(cmd *cobra.Command, args []string) error {
		results := model.SearchAttributeView(args[0], nil, "", "")
		switch outputFormat {
		case "json":
			return printJSON(results)
		default:
			printAvSearchResults(results)
		}
		return nil
	},
}

var databaseGetCmd = &cobra.Command{
	Use:   "get --av <avID>",
	Short: "Get database content",
	RunE: func(cmd *cobra.Command, args []string) error {
		avID, _ := cmd.Flags().GetString("av")
		if avID == "" {
			return fmt.Errorf("--av is required")
		}
		attrView := model.GetAttributeView(avID)
		if attrView == nil {
			return fmt.Errorf("database not found: %s", avID)
		}
		switch outputFormat {
		case "json":
			return printJSON(model.NewAttributeViewMetadata(attrView))
		default:
			printDatabaseMetadata(attrView)
		}
		return nil
	},
}

var databaseRenderCmd = &cobra.Command{
	Use:   "render --av <avID>",
	Short: "Render database data",

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Locate the database block ID (e.g. via `siyuan block get` on the doc containing it) and pass it as `--av`
  2. Run `siyuan database get --av <avID> --output json` to inspect metadata
  3. Confirm the flag is `--av`, not `--id` or `--database`

Example fix

// before
siyuan database get

// after
siyuan database get --av 20240101000000-av12345
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(avID) == "" {
    log.Fatal("--av is required")
}

Prevention

When it happens

Trigger: Running `siyuan database get` with no `--av`, or `--av ""`, or referencing an unset variable.

Common situations: Confusing the database block ID with the AV ID, or not knowing where the AV ID comes from (it is the database block's data ID).

Related errors


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