siyuan-note/siyuan · error
ErrAttributeViewNotFound
ErrAttributeViewNotFound
Error message
attribute view not found
What it means
ErrAttributeViewNotFound is the package-level sentinel of the av package meaning the requested attribute view (database) does not exist or is not accessible to the caller. Public API handlers also reuse its message as the response for read-only/publish contexts where AV access is denied, so it doubles as an access-denied marker in those HTTP endpoints.
Source
Thrown at kernel/av/av.go:1339
}
av := filepath.Join(util.DataDir, "storage", "av")
ret = filepath.Join(av, avID+".json")
if !gulu.File.IsDir(av) {
if err := os.MkdirAll(av, 0755); err != nil {
logging.LogErrorf("create attribute view dir failed: %s", err)
return
}
}
return
}
func GetAttributeViewI18n(key string) string {
return util.AttrViewLangs[util.Lang][key].(string)
}
var (
ErrAttributeViewNotFound = errors.New("attribute view not found")
ErrInvalidAttributeViewID = errors.New("invalid attribute view id")
ErrInvalidBoxID = errors.New("invalid box id")
ErrViewNotFound = errors.New("view not found")
ErrKeyNotFound = errors.New("key not found")
ErrItemNotFound = errors.New("item not found")
ErrWrongLayoutType = errors.New("wrong layout type")
ErrInvalidColumnAlign = errors.New("invalid column align")
ErrSpecTooNew = errors.New("attribute view spec is too new")
ErrRichTextSpecMismatch = errors.New("attribute view rich text requires storage spec 9")
ErrFilterTooDeep = errors.New("filter nesting depth exceeds the maximum allowed")
)
const (
NodeAttrNameAvs = "custom-avs" // 用于标记块所属的属性视图,逗号分隔 av id
NodeAttrView = "custom-sy-av-view" // 用于标记块所属的属性视图视图 view id Database block support specified view https://github.com/siyuan-note/siyuan/issues/10443
NodeAttrVisibleViewIDs = "custom-sy-av-visible-views" // 用于标记数据库块显示的视图 ID,逗号分隔
NodeAttrContextFilter = "custom-sy-av-context-filter" // 用于保存数据库块独有的上下文筛选配置
NodeAttrViewStaticText = "custom-sy-av-s-text" // 用于标记块所属的属性视图静态文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049View on GitHub (pinned to 8641553a1f)
Solutions
- Verify the avID exists: check for <doc-id>.av under the notebook's storage/av directory
- Re-obtain the avID from the block's attributes (custom-av) instead of hardcoding it
- If hitting the publish/read-only API, grant the AV access in publish access settings or call with proper authorization
- Recreate the attribute view if it was intentionally deleted
Example fix
// before
keys, err := av.GetAttributeViewKeysByID(avID) // ErrAttributeViewNotFound
// after
if _, statErr := os.Stat(filepath.Join(dataDir, boxID, "storage", "av", avID+".av")); statErr != nil {
return nil, fmt.Errorf("av %s does not exist in notebook %s", avID, boxID)
}
keys, err := av.GetAttributeViewKeysByID(avID) Defensive patterns
Strategy: validation
Validate before calling
if !ast.IsNodeIDPattern(avID) || !filelock.IsExist(filepath.Join(dataDir, boxID, "storage", "av", avID+".av")) {
return errors.New("attribute view does not exist")
} Type guard
func avExists(dataDir, boxID, avID string) bool {
return ast.IsNodeIDPattern(avID) && filelock.IsExist(filepath.Join(dataDir, boxID, "storage", "av", avID+".av"))
} Try / catch
keys, err := av.GetAttributeViewKeysByID(avID)
if errors.Is(err, av.ErrAttributeViewNotFound) {
http.Error(w, "database not found", http.StatusNotFound)
return
} Prevention
- Always fetch avIDs dynamically from the block's attributes, never hardcode them
- Check publish access rules before calling read-only endpoints on an AV
- After deleting a database, clean up plugins/scripts that reference its avID
When it happens
Trigger: Calling getAttributeViewKeysByID, RenderAttributeViewWithTarget, or ResolveRepoSnapshotAttributeViewBoxID with an avID that has no .av file; HTTP API calls to /api/av/* where model.CheckAttributeView(Access)ableByPublishAccess fails (publish/read-only mode without access) and ret.Msg is set to this error's text.
Common situations: A plugin or script referencing a deleted database; a hardcoded avID from another workspace; accessing a published/read-only kernel endpoint for an AV the publish access rules don't allow; snapshot restore where the AV JSON is missing.
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@8641553a1f (2026-09-11).
Data as JSON: /api/errors/c19791224a62b295.
Report an issue: GitHub.