siyuan-note/siyuan · error

database not found

Error message

database not found: %s

What it means

`database get` found the `--av` flag non-empty, but model.GetAttributeView returned nil — no attribute view with that ID exists (or it failed to load). The command turns the nil lookup result into this error naming the requested ID.

Solutions

  1. Verify the av ID — open the database block and copy its ID (the `custom-av`/av ID, not the block ID)
  2. Run in the correct workspace (`--workspace`) where the database exists
  3. List databases via the SQL/API to confirm the ID exists
  4. Re-check the ID for truncation or typos

Example fix

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

Strategy: validation

Validate before calling

test -n "$AV_ID" && siyuan database get --av "$AV_ID" || echo "av id missing or database absent"

Prevention

When it happens

Trigger: Running `siyuan database get --av <id>` where the ID does not correspond to any existing attribute view in the workspace.

Common situations: Using a block ID instead of the database (av) ID; the database was deleted or renamed since the script was written; working against a different workspace than where the database lives; truncated or mistyped IDs.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — 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/b91b2b2e6eac9cc4. Report an issue: GitHub.

Appendix: source

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

			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",
	RunE: func(cmd *cobra.Command, args []string) error {
		avID, _ := cmd.Flags().GetString("av")
		viewID, _ := cmd.Flags().GetString("view")
		query, _ := cmd.Flags().GetString("query")

View on GitHub (pinned to 9f775e8a12)