{"record":{"id":"b91b2b2e6eac9cc4","repo":"siyuan-note/siyuan","slug":"database-not-found-s","errorCode":null,"errorMessage":"database not found: %s","messagePattern":"database not found: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/database.go","lineNumber":65,"sourceCode":"\t\t\treturn printJSON(results)\n\t\tdefault:\n\t\t\tprintAvSearchResults(results)\n\t\t}\n\t\treturn nil\n\t},\n}\n\nvar databaseGetCmd = &cobra.Command{\n\tUse:   \"get --av <avID>\",\n\tShort: \"Get database content\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tavID, _ := cmd.Flags().GetString(\"av\")\n\t\tif avID == \"\" {\n\t\t\treturn fmt.Errorf(\"--av is required\")\n\t\t}\n\t\tattrView := model.GetAttributeView(avID)\n\t\tif attrView == nil {\n\t\t\treturn fmt.Errorf(\"database not found: %s\", avID)\n\t\t}\n\t\tswitch outputFormat {\n\t\tcase \"json\":\n\t\t\treturn printJSON(model.NewAttributeViewMetadata(attrView))\n\t\tdefault:\n\t\t\tprintDatabaseMetadata(attrView)\n\t\t}\n\t\treturn nil\n\t},\n}\n\nvar databaseRenderCmd = &cobra.Command{\n\tUse:   \"render --av <avID>\",\n\tShort: \"Render database data\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tavID, _ := cmd.Flags().GetString(\"av\")\n\t\tviewID, _ := cmd.Flags().GetString(\"view\")\n\t\tquery, _ := cmd.Flags().GetString(\"query\")","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/database.go#L47-L83","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the database block exists and copy its AV data ID (not the wrapping block ID)","Search blocks/SQL to locate the correct AV ID for your database","If recently deleted, restore from history/snapshot; otherwise recreate the database"],"exampleFix":"// before\nsiyuan database get --av wrong-id-123\n\n// after\nsiyuan database get --av 20240101000000-av12345","handlingStrategy":"validation","validationCode":"av := model.GetAttributeView(avID)\nif av == nil {\n    // AV file missing or unparseable; handle before proceeding\n    return fmt.Errorf(\"database %s does not exist\", avID)\n}","typeGuard":"func avExists(avID string) bool {\n    return model.GetAttributeView(avID) != nil\n}","tryCatchPattern":"av := model.GetAttributeView(avID)\nif av == nil {\n    // recover: search for the correct AV ID or prompt user\n}","preventionTips":["Validate the AV ID resolves before any get/keys/render call","Keep AV IDs versioned alongside the workspace they belong to","Restore deleted databases from history rather than reusing stale IDs"],"tags":["cli","database","attribute-view","not-found","lookup-failure"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}