{"record":{"id":"412193756e83b0b2","repo":"siyuan-note/siyuan","slug":"invalid-date-display-format","errorCode":null,"errorMessage":"invalid date display format","messagePattern":"invalid date display format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view.go","lineNumber":7484,"sourceCode":"\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\n\tfor _, view := range attrView.Views {\n\t\tnewField := &av.BaseField{ID: key.ID}\n\t\tif nil != view.Table {\n\t\t\tnewField.Wrap = view.Table.WrapField\n\n\t\t\tif \"\" == previousKeyID {","sourceCodeStart":7466,"sourceCodeEnd":7502,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view.go#L7466-L7502","documentation":"For date-family columns (date, created, updated), the kernel validates the supplied av.DateDisplayFormat via IsValid() before assigning it to the key. An unrecognized format string aborts key creation with this error.","triggerScenarios":"Calling add-attribute-view-key with type \"date\"/\"created\"/\"updated\" and a dateFormat parameter not matching any valid DateDisplayFormat enum value.","commonSituations":"Passing free-form Go-style or moment-style format strings (\"2006-01-02\", \"YYYY-MM-DD\") instead of the kernel's enum names; older clients sending a format removed in a later version.","solutions":["Use a valid av.DateDisplayFormat value (check the av package / petal typings for the accepted strings)","Omit the custom format to use the default when unsure","Normalize any client-side format translation layer before sending"],"exampleFix":"// before\naddAttrViewKey(avID, keyID, name, \"date\", \"\", \"YYYY-MM-DD\")\n// after\naddAttrViewKey(avID, keyID, name, \"date\", \"\", \"20060102\") // a valid DateDisplayFormat value","handlingStrategy":"validation","validationCode":"const VALID_DATE_FORMATS = [/* av.DateDisplayFormat values, see petal typings */];\nif (isDateType && !VALID_DATE_FORMATS.includes(dateFormat)) throw new Error(`invalid date display format: ${dateFormat}`);","typeGuard":"type DateDisplayFormat = typeof VALID_DATE_FORMATS[number];\nconst isDateFormat = (s: string): s is DateDisplayFormat => VALID_DATE_FORMATS.includes(s);","tryCatchPattern":"try { await addAttrViewKey(...); } catch (e) { if (String(e).includes(\"invalid date display format\")) { /* retry with default format */ } else throw e; }","preventionTips":["Import format constants from petal instead of typing them by hand","Do not substitute strftime/moment tokens for kernel format names","Unit-test key creation with each date type"],"tags":["attribute-view","date-format","validation"],"backgroundTag":"invalid-date-format","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"}