siyuan-note/siyuan · error

--av is required

Error message

--av is required

What it means

The `database get` subcommand requires `--av` to identify the attribute view (database) to read. When the flag is empty, RunE returns this error before calling model.GetAttributeView. It distinguishes a missing argument from a not-found database (error 504).

Solutions

  1. Pass `--av <avID>` with the database ID from the block's `custom-av` attribute or the database panel
  2. Confirm flag spelling is exactly `--av`
  3. Echo the av variable in scripts to confirm it is non-empty before invoking

Example fix

// before
siyuan database get
// after
siyuan database get --av 20240101120000-avxyz
Defensive patterns

Strategy: validation

Validate before calling

if [ -z "$AV_ID" ]; then echo "--av is required"; exit 1; fi
siyuan database get --av "$AV_ID"

Prevention

When it happens

Trigger: Running `siyuan database get` without `--av`, or with `--av ""`.

Common situations: Copy-pasting commands and dropping the flag; extracting av IDs from URLs and ending up with an empty variable in shell scripts; typos like `--attr-view`.

Understand the failure class

Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/bf2533fb769171c5. Report an issue: GitHub.

Appendix: 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 9f775e8a12)