{"record":{"id":"ba42644eb99ffd80","repo":"siyuan-note/siyuan","slug":"unsupported-attribute-view-key-type-s","errorCode":null,"errorMessage":"unsupported attribute view key type [%s]","messagePattern":"unsupported attribute view key type \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view.go","lineNumber":7478,"sourceCode":"\tif nil != err {\n\t\treturn err\n\t}\n\taddAttributeViewKey(attrView, currentView, key, previousKeyID)\n\n\terr = av.SaveAttributeView(attrView)\n\treturn\n}\n\nfunc newAttributeViewKey(keyID, keyName, keyType, keyIcon string, dateFormat av.DateDisplayFormat) (ret *av.Key, err error) {\n\tkeyTyp := av.KeyType(keyType)\n\tswitch keyTyp {\n\tcase av.KeyTypeBlock:\n\t\treturn nil, errors.New(\"cannot add an attribute view block key\")\n\tcase av.KeyTypeText, av.KeyTypeNumber, av.KeyTypeDate, av.KeyTypeSelect, av.KeyTypeMSelect, av.KeyTypeURL, av.KeyTypeEmail,\n\t\tav.KeyTypePhone, av.KeyTypeMAsset, av.KeyTypeTemplate, av.KeyTypeCreated, av.KeyTypeUpdated, av.KeyTypeCheckbox,\n\t\tav.KeyTypeRelation, av.KeyTypeRollup, av.KeyTypeLineNumber:\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported attribute view key type [%s]\", keyType)\n\t}\n\n\tret = av.NewKey(keyID, keyName, filterAttrViewIconValue(keyIcon), keyTyp)\n\tif av.KeyTypeDate == keyTyp || av.KeyTypeCreated == keyTyp || av.KeyTypeUpdated == keyTyp {\n\t\tif !dateFormat.IsValid() {\n\t\t\treturn nil, errors.New(\"invalid date display format\")\n\t\t}\n\t\tret.DateFormat = dateFormat\n\t}\n\tif av.KeyTypeRollup == keyTyp {\n\t\tret.Rollup = &av.Rollup{Calc: &av.RollupCalc{Operator: av.CalcOperatorNone}}\n\t}\n\treturn\n}\n\nfunc addAttributeViewKey(attrView *av.AttributeView, currentView *av.View, key *av.Key, previousKeyID string) {\n\tattrView.KeyValues = append(attrView.KeyValues, &av.KeyValues{Key: key})\n","sourceCodeStart":7460,"sourceCodeEnd":7496,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view.go#L7460-L7496","documentation":"newAttributeViewKey only accepts a fixed whitelist of key types (text, number, date, select, mSelect, url, email, phone, mAsset, template, created, updated, checkbox, relation, rollup, lineNumber). Any other string falls to the default branch and is rejected with the type echoed in the message.","triggerScenarios":"Calling add-attribute-view-key with a misspelled or nonexistent type string (e.g. \"Text\", \"mulit-select\", \"assets\").","commonSituations":"Case-sensitivity mistakes; outdated plugin using a removed/renamed type name; hand-written API scripts guessing type names.","solutions":["Use one of the exact supported type strings (lowercase, e.g. \"text\", \"mSelect\", \"mAsset\")","Compare against av.KeyType constants in the petal/plugin typings","Update plugin code to current type names if it predates a rename"],"exampleFix":"// before\naddAttrViewKey(avID, keyID, name, \"Text\", \"\", \"\")\n// after\naddAttrViewKey(avID, keyID, name, \"text\", \"\", \"\")","handlingStrategy":"type-guard","validationCode":"const ADDABLE_TYPES = [\"text\",\"number\",\"date\",\"select\",\"mSelect\",\"url\",\"email\",\"phone\",\"mAsset\",\"template\",\"created\",\"updated\",\"checkbox\",\"relation\",\"rollup\",\"lineNumber\"];\nif (!ADDABLE_TYPES.includes(keyType)) throw new Error(`unsupported key type: ${keyType}`);","typeGuard":"type AddableKeyType = typeof ADDABLE_TYPES[number];\nconst isAddable = (t: string): t is AddableKeyType => ADDABLE_TYPES.includes(t);","tryCatchPattern":"try { await addAttrViewKey(...); } catch (e) { const m = String(e).match(/unsupported attribute view key type \\[(.+)\\]/); if (m) { console.error(`fix type \"${m[1]}\"`); } else throw e; }","preventionTips":["Use a typed union for key types instead of raw strings","Copy type names from av.KeyType constants, not memory","Watch for renames when upgrading against a new kernel"],"tags":["attribute-view","invalid-enum","api"],"backgroundTag":"invalid-enum-argument","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}