siyuan-note/siyuan · error
ErrAttributeViewNotFound
ErrAttributeViewNotFound
Error message
attribute view not found
What it means
ErrAttributeViewNotFound is the sentinel error returned whenever a requested attribute view (by ID, or by block binding) cannot be found or the caller lacks access under the current role. The HTTP layer translates publish-access denials into this same message so unauthorized/not-found requests are indistinguishable.
Solutions
- Verify the avID/blockID exists in the workspace (check for the corresponding .av file under data/storage/av)
- Confirm access permissions — for published spaces check publish access rules allow the requested AV
- Refresh/re-sync the workspace in case a delete or sync left stale references, then retry
- Regenerate the ID from the actual database block in the UI and use that in the API call
Example fix
// before
fetchPost("/api/av/getAttributeViewKeysByID", {avID: "20240101120000-abcdef"})
// after
const blocks = await fetchPost("/api/query/sql", {stmt: "SELECT block_id FROM blocks WHERE id='...'"})
// derive the real avID from an existing attribute-view block, then call the API Defensive patterns
Strategy: try-catch
Validate before calling
const exists = await fetchPost("/api/query/sql", {stmt: "SELECT id FROM blocks WHERE id='" + blockID + "'"})
if (!exists || exists.length === 0) throw new Error("block/attribute view not found") Type guard
function isNotFound(resp) { return resp && resp.code === -1 && resp.msg === "attribute view not found"; } Try / catch
try {
return await fetchPost("/api/av/getAttributeViewKeysByID", {avID})
} catch (e) {
if (e.message.includes("attribute view not found")) {
// re-resolve the avID from the block, check publish permissions, or resync
}
throw e
} Prevention
- Resolve avIDs from real database blocks rather than hard-coding them
- Check publish/read access rules when serving through published spaces
- After deletions or sync, refresh stale references before querying AVs
When it happens
Trigger: Calling endpoints like getAttributeViewKeysByID or rendering an AV block with an avID/blockID that does not exist; access via publish (read-only) role where CheckAttributeViewAccessableByPublishAccess fails; a stale block ID referencing a deleted database; tests validate this sentinel on access-before-key checks.
Common situations: Copy-pasted avID with a typo or from another workspace; the database block was deleted or the .av file removed while clients still reference it; publishing access rules blocking the key; sync leaving a block referencing a missing AV.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- attribute view not found
- attribute view [ ] is not bound
- attribute view [ ] not found in box [ ]
- attribute view [ ] view [ ] not found
- attribute view [ ] visible view [ ] not found
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/c19791224a62b295.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/av/av.go:1383
}
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 9f775e8a12)