{"record":{"id":"efe0da854916af88","repo":"siyuan-note/siyuan","slug":"invalid-attribute-view-id","errorCode":null,"errorMessage":"invalid attribute view id","messagePattern":"invalid attribute view id","errorType":"error_code","errorClass":"ErrInvalidAttributeViewID","httpStatus":null,"severity":"error","filePath":"kernel/av/av.go","lineNumber":1294,"sourceCode":"\n\tav := filepath.Join(util.DataDir, \"storage\", \"av\")\n\tret = filepath.Join(av, avID+\".json\")\n\tif !gulu.File.IsDir(av) {\n\t\tif err := os.MkdirAll(av, 0755); err != nil {\n\t\t\tlogging.LogErrorf(\"create attribute view dir failed: %s\", err)\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}\n\nfunc GetAttributeViewI18n(key string) string {\n\treturn util.AttrViewLangs[util.Lang][key].(string)\n}\n\nvar (\n\tErrAttributeViewNotFound  = errors.New(\"attribute view not found\")\n\tErrInvalidAttributeViewID = errors.New(\"invalid attribute view id\")\n\tErrInvalidBoxID           = errors.New(\"invalid box id\")\n\tErrViewNotFound           = errors.New(\"view not found\")\n\tErrKeyNotFound            = errors.New(\"key not found\")\n\tErrItemNotFound           = errors.New(\"item not found\")\n\tErrWrongLayoutType        = errors.New(\"wrong layout type\")\n\tErrInvalidColumnAlign     = errors.New(\"invalid column align\")\n\tErrSpecTooNew             = errors.New(\"attribute view spec is too new\")\n\tErrFilterTooDeep          = errors.New(\"filter nesting depth exceeds the maximum allowed\")\n)\n\nconst (\n\tNodeAttrNameAvs        = \"custom-avs\"                 // 用于标记块所属的属性视图，逗号分隔 av id\n\tNodeAttrView           = \"custom-sy-av-view\"          // 用于标记块所属的属性视图视图 view id Database block support specified view https://github.com/siyuan-note/siyuan/issues/10443\n\tNodeAttrVisibleViewIDs = \"custom-sy-av-visible-views\" // 用于标记数据库块显示的视图 ID，逗号分隔\n\tNodeAttrViewStaticText = \"custom-sy-av-s-text\"        // 用于标记块所属的属性视图静态文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049\n\n\tNodeAttrViewNames = \"av-names\" // 用于临时标记块所属的属性视图名称，空格分隔\n)","sourceCodeStart":1276,"sourceCodeEnd":1312,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/av/av.go#L1276-L1312","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ncallAVAPI(someBlockID)   // wrong id type -> invalid attribute view id\n\n// after: pass the database (av) id, validated\nif !ast.IsNodeIDPattern(avID) { return ErrInvalidAttributeViewID }\ncallAVAPI(avID)","handlingStrategy":"validation","validationCode":"// Validate the id shape before any AV call\nif !ast.IsNodeIDPattern(avID) {\n    return fmt.Errorf(\"not a valid attribute view id: %q\", avID)\n}","typeGuard":"// TypeScript guard for the frontend\nfunction isNodeID(id: string): boolean {\n  return /^\\d{14}[0-9a-z]+$/.test(id)\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["attribute-view","validation","id","api"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}