{"record":{"id":"dd5f0850928c0d7a","repo":"siyuan-note/siyuan","slug":"template-requires-a-template-field-use-rendertemplate-for","errorCode":null,"errorMessage":"template requires a template field; use renderTemplate for other fields","messagePattern":"template requires a template field; use renderTemplate for other fields","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view_key_config.go","lineNumber":75,"sourceCode":"\t\t\t\tif _, err = newAttributeViewKey(keyID, key.Name, text, key.Icon, key.DateFormat); nil != err {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\top.Typ = text\n\t\t\t\treturn updateAttributeViewColumn(op)\n\t\t\tcase \"icon\":\n\t\t\t\treturn setAttributeViewColIcon(op)\n\t\t\tcase \"desc\":\n\t\t\t\treturn setAttributeViewColDesc(op)\n\t\t\tcase \"numberFormat\":\n\t\t\t\tif av.KeyTypeNumber != key.Type || !slices.Contains(AttributeViewKeyNumberFormats, text) {\n\t\t\t\t\treturn errors.New(\"numberFormat requires a number field and a supported format\")\n\t\t\t\t}\n\t\t\t\treturn updateAttributeViewColNumberFormat(op)\n\t\t\tcase \"dateFormat\":\n\t\t\t\treturn setAttributeViewColDateFormat(op)\n\t\t\tcase \"template\":\n\t\t\t\tif av.KeyTypeTemplate != key.Type {\n\t\t\t\t\treturn errors.New(\"template requires a template field; use renderTemplate for other fields\")\n\t\t\t\t}\n\t\t\t\treturn updateAttributeViewColTemplate(op)\n\t\t\tcase \"renderTemplate\":\n\t\t\t\tif av.KeyTypeTemplate == key.Type {\n\t\t\t\t\treturn errors.New(\"use template for a template field\")\n\t\t\t\t}\n\t\t\t\treturn updateAttributeViewColTemplate(op)\n\t\t\t}\n\t\tcase \"autoFillNow\", \"fillSpecificTime\", \"includeTime\":\n\t\t\tflag, ok := value.(bool)\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"%s must be a boolean\", setting)\n\t\t\t}\n\t\t\top.Data = flag\n\t\t\tif \"includeTime\" == setting {\n\t\t\t\tswitch key.Type {\n\t\t\t\tcase av.KeyTypeCreated:\n\t\t\t\t\treturn setAttrViewCreatedIncludeTime(op)","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view_key_config.go#L57-L93","documentation":"The \"template\" setting is only valid for fields of type KeyTypeTemplate; other field types must use \"renderTemplate\" to set their rendered template. Passing \"template\" for a non-template field is rejected to keep template-type configuration separate from display-render templates.","triggerScenarios":"Calling UpdateAttributeViewKeyConfig with {\"template\": \".foo\"} on a text, number, or date field instead of {\"renderTemplate\": ...}.","commonSituations":"Plugin authors confusing the template field formula with the render template of regular columns; API payloads copied from template-field examples and reused for other column types.","solutions":["Use {\"renderTemplate\": \"...\"} for non-template fields","Create the field as a template type first if a computed formula column is wanted","Branch on key.Type in client code: template -> \"template\", anything else -> \"renderTemplate\""],"exampleFix":"// before\nupdateKeyConfig(avID, textKeyID, {\"template\": \"{name}\"})\n// after\nupdateKeyConfig(avID, textKeyID, {\"renderTemplate\": \"{name}\"})","handlingStrategy":"validation","validationCode":"function assertTemplateSetting(key, setting) { if (setting === 'template' && key.type !== 'template') throw new Error('use renderTemplate for non-template fields'); if (setting === 'renderTemplate' && key.type === 'template') throw new Error('use template for a template field'); }","typeGuard":"const isTemplateField = (key) => key?.type === 'template';","tryCatchPattern":"try { await updateKeyConfig(avID, keyID, { template: value }); } catch (e) { if (/template requires a template field/.test(e.message)) { return updateKeyConfig(avID, keyID, { renderTemplate: value }); } throw e; }","preventionTips":["Branch on field type: template fields use \"template\", all others use \"renderTemplate\"","Copy API examples from matching field types only","Wrap config updates in a helper that maps setting name to field type"],"tags":["api","validation","attribute-view","field-type"],"backgroundTag":"unsupported-operation","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"}