siyuan-note/siyuan · error

database not found: %s

Error message

database not found: %s

What it means

Thrown by `database get` when `--av` is non-empty but `model.GetAttributeView(avID)` returns nil. `GetAttributeView` (attribute_view.go:2736) calls `av.ParseAttributeView(avID)` which returns nil when the AV JSON file cannot be found on disk or fails to parse. This means the ID was syntactically accepted but does not resolve to a real database.

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 251596fc0d)

Solutions

  1. Confirm the database block exists and copy its AV data ID (not the wrapping block ID)
  2. Search blocks/SQL to locate the correct AV ID for your database
  3. If recently deleted, restore from history/snapshot; otherwise recreate the database

Example fix

// before
siyuan database get --av wrong-id-123

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

Strategy: validation

Validate before calling

av := model.GetAttributeView(avID)
if av == nil {
    // AV file missing or unparseable; handle before proceeding
    return fmt.Errorf("database %s does not exist", avID)
}

Type guard

func avExists(avID string) bool {
    return model.GetAttributeView(avID) != nil
}

Try / catch

av := model.GetAttributeView(avID)
if av == nil {
    // recover: search for the correct AV ID or prompt user
}

Prevention

When it happens

Trigger: Passing a wrong/deleted/non-existent AV ID, a typo in the ID, an ID from a different workspace, or an AV whose `.json` file was removed/corrupted.

Common situations: Using a document block ID instead of the database (AV) ID, stale ID copied from an old workspace, or referencing a database that was deleted.

Related errors


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