{"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/251596fc0de2f9528c00c224252fd073a99973f4/kernel/av/new_item_template.go#L326-L362","documentation":"fieldValue.Mode is neither NewItemFieldValueCurrentTime nor NewItemFieldValueStatic. An empty Mode is silently defaulted to Static (new_item_template.go:319), so this branch only fires for an explicit, unrecognized mode string — typically a value from a newer or typo'd client.","triggerScenarios":"Client sends a future mode value the running kernel does not recognize; a typo in the mode string; corrupted payload or version skew.","commonSituations":"Version skew after a new mode is added on the client but the kernel is not upgraded; manually authored JSON with a wrong mode literal.","solutions":["Send one of the two canonical mode constants defined in the av package.","Leave Mode empty (\"\") if you want the default Static behavior.","Upgrade the kernel if a newer mode is required."],"exampleFix":"// before\nFieldValues[\"k\"] = &av.NewItemFieldValue{Mode: \"auto\"}\n// after\nFieldValues[\"k\"] = &av.NewItemFieldValue{Mode: av.NewItemFieldValueStatic}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func isValidFieldValueMode(m string) bool {\n    return m == \"\" || m == av.NewItemFieldValueStatic || m == av.NewItemFieldValueCurrentTime\n}","tryCatchPattern":null,"preventionTips":["Reference the av package mode constants, never literals.","Leave Mode empty (\"\") to get the Static default.","Upgrade the kernel if a newer mode is required."],"tags":["av","new-item-template","mode","validation","enum"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}