siyuan-note/siyuan · error · ErrInvalidAttributeViewID
invalid attribute view id
Error message
invalid attribute view id
What it means
Sentinel ErrInvalidAttributeViewID. Returned by ParseAttributeView, ParseAttributeViewInBox, SaveAttributeView, and encrypted_hook.go when the avID fails ast.IsNodeIDPattern — i.e. it is not a valid SiYuan node id (14-digit timestamp-style string). This guards every AV entry point against malformed ids before any disk access.
Source
Thrown at kernel/av/av.go:1294
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")
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,逗号分隔
NodeAttrViewStaticText = "custom-sy-av-s-text" // 用于标记块所属的属性视图静态文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049
NodeAttrViewNames = "av-names" // 用于临时标记块所属的属性视图名称,空格分隔
)View on GitHub (pinned to 251596fc0d)
Solutions
- Ensure the avID is the database's own id (match the ^\d{14}[0-9a-z]+$ node-id pattern), not a block id or view id.
- Validate client-side before the call: if (!/^\d{14}[0-9a-z]+$/.test(avID)) return.
- Check that the field is populated and not truncated by string slicing.
Example fix
// before
callAVAPI(someBlockID) // wrong id type -> invalid attribute view id
// after: pass the database (av) id, validated
if !ast.IsNodeIDPattern(avID) { return ErrInvalidAttributeViewID }
callAVAPI(avID) Defensive patterns
Strategy: validation
Validate before calling
// Validate the id shape before any AV call
if !ast.IsNodeIDPattern(avID) {
return fmt.Errorf("not a valid attribute view id: %q", avID)
} Type guard
// TypeScript guard for the frontend
function isNodeID(id: string): boolean {
return /^\d{14}[0-9a-z]+$/.test(id)
} Prevention
- Use the database's own avID, never a block or view id, in the avID slot.
- Guard against undefined/empty ids at the call site.
- Keep a single source of truth for the avID in the client.
When it happens
Trigger: Calling an AV API with an empty, typo'd, or non-id avID: '', 'abc', '20210301', a full UUID, or a value with whitespace/special chars. Any string not matching the canonical id pattern.
Common situations: Frontend bug sending an undefined/empty avID; a plugin constructing ids manually; copy-paste of a wrong field; passing a block id where an avID was expected.
Related errors
- invalid box id
- wrong layout type
- invalid column align
- filter nesting depth exceeds the maximum allowed
- invalid id
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/efe0da854916af88.
Report an issue: GitHub.