{"record":{"id":"2c6b54ba06e5bba1","repo":"siyuan-note/siyuan","slug":"invalid-new-item-template-field-value-mode-s","errorCode":null,"errorMessage":"invalid new item template field value mode [%s]","messagePattern":"invalid new item template field value mode \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/new_item_template.go","lineNumber":344,"sourceCode":"\t\t\t}\n\t\t\tfieldValue.Value = nil\n\t\tcase NewItemFieldValueStatic:\n\t\t\tif nil == fieldValue.Value {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfieldValue.Value, err = normalizeNewItemTemplateValue(fieldValue.Value, key)\n\t\t\tif nil != err {\n\t\t\t\treturn fmt.Errorf(\"new item template field [%s] value is invalid: %w\", keyID, err)\n\t\t\t}\n\t\t\tif KeyTypeSelect == key.Type || KeyTypeMSelect == key.Type {\n\t\t\t\tfor _, selection := range fieldValue.Value.MSelect {\n\t\t\t\t\tif nil != selection && nil == key.GetOption(selection.Content) {\n\t\t\t\t\t\treturn fmt.Errorf(\"new item template field [%s] option [%s] not found\", keyID, selection.Content)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"invalid new item template field value mode [%s]\", fieldValue.Mode)\n\t\t}\n\t\tfieldValues[keyID] = fieldValue\n\t}\n\tif 0 == len(fieldValues) {\n\t\titemTemplate.FieldValues = nil\n\t} else {\n\t\titemTemplate.FieldValues = fieldValues\n\t}\n\treturn nil\n}\n\nfunc normalizeNewItemTemplateValue(value *Value, key *Key) (*Value, error) {\n\tvalue = value.Clone()\n\tswitch key.Type {\n\tcase KeyTypeText:\n\t\tif nil == value.Text {\n\t\t\treturn nil, errors.New(\"text value is missing\")\n\t\t}","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/av/new_item_template.go#L326-L362","documentation":"Field value modes are restricted to the known constants NewItemFieldValueStatic and NewItemFieldValueCurrentTime. Any other Mode string falls into the switch's default branch and rejects the configuration, because the template engine cannot interpret an unknown fill mode.","triggerScenarios":"Calling SetNewItemTemplates with FieldValues[keyID].Mode set to an unrecognized string (typo, empty handled separately by defaulting to static — so this requires an explicit unknown value such as \"now\" or \"formula\").","commonSituations":"Plugins inventing custom fill modes not supported by the kernel; configs written by a newer/older version using modes that no longer exist; hand-editing persisted JSON with a misspelled mode.","solutions":["Set Mode to av.NewItemFieldValueStatic for fixed pre-filled values","Set Mode to av.NewItemFieldValueCurrentTime (date fields only) for creation timestamps","Leave Mode as empty string if unsure — it defaults to static automatically"],"exampleFix":"// before\nfv.Mode = \"now\"\nerr := av.SetNewItemTemplates(config)\n// after\nfv.Mode = av.NewItemFieldValueCurrentTime\nerr := av.SetNewItemTemplates(config)","handlingStrategy":"validation","validationCode":"if fv.Mode != av.NewItemFieldValueStatic && fv.Mode != av.NewItemFieldValueCurrentTime && fv.Mode != \"\" {\n\treturn fmt.Errorf(\"unsupported mode %q\", fv.Mode)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only the exported NewItemFieldValue* constants","Leave Mode empty to get the static default instead of inventing values"],"tags":["attribute-view","validation","enum"],"backgroundTag":"invalid-enum-value","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"}