{"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":6968,"sourceCode":"\t}\n\n\tcurrentView, err := getAttrViewViewByBlockID(attrView, blockID)\n\tif nil != err {\n\t\treturn\n\t}\n\n\tkeyTyp := av.KeyType(keyType)\n\tswitch keyTyp {\n\tcase av.KeyTypeBlock:\n\t\treturn 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\n\t\tkey := av.NewKey(keyID, keyName, filterAttrViewIconValue(keyIcon), keyTyp)\n\t\tif av.KeyTypeDate == keyTyp || av.KeyTypeCreated == keyTyp || av.KeyTypeUpdated == keyTyp {\n\t\t\tif !dateFormat.IsValid() {\n\t\t\t\treturn errors.New(\"invalid date display format\")\n\t\t\t}\n\t\t\tkey.DateFormat = dateFormat\n\t\t}\n\t\tif av.KeyTypeRollup == keyTyp {\n\t\t\tkey.Rollup = &av.Rollup{Calc: &av.RollupCalc{Operator: av.CalcOperatorNone}}\n\t\t}\n\n\t\tattrView.KeyValues = append(attrView.KeyValues, &av.KeyValues{Key: key})\n\n\t\tfor _, view := range attrView.Views {\n\t\t\tnewField := &av.BaseField{ID: key.ID}\n\t\t\tif nil != view.Table {\n\t\t\t\tnewField.Wrap = view.Table.WrapField\n\n\t\t\t\tif \"\" == previousKeyID {\n\t\t\t\t\tif av.LayoutTypeGallery == currentView.LayoutType || av.LayoutTypeKanban == currentView.LayoutType {\n\t\t\t\t\t\t// 如果当前视图是卡片或看板视图则添加到最后\n\t\t\t\t\t\tview.Table.Columns = append(view.Table.Columns, &av.ViewTableColumn{BaseField: newField})","sourceCodeStart":6950,"sourceCodeEnd":6986,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/attribute_view.go#L6950-L6986","documentation":"Thrown by AddAttributeViewKey when adding a date, created, or updated key whose dateFormat does not pass av.DateDisplayFormat.IsValid(). The format must be one of the recognized date-display-format enum values; any other string is rejected before the key is created.","triggerScenarios":"Sending operation.Format with an empty string, a custom format, or a value from an older/newer kernel version whose enum set differs. Reached when a caller omits Format for a date-type key or passes a raw moment/dayjs format string instead of the kernel enum.","commonSituations":"Frontend version skew (new format value not yet known to the running kernel); a plugin hard-coding a format string; manual API call that leaves Format blank.","solutions":["Use only date-format values returned by the kernel's format enumeration when constructing add-column operations for date/created/updated keys.","Default to a known-good format (e.g. the kernel's default) when the user does not pick one, instead of sending an empty string.","Align frontend and kernel versions so the format enum sets match."],"exampleFix":"// before\nAddAttributeViewKey(avID, blockID, keyID, name, 'date', icon, prevID, '')\n// after\nAddAttributeViewKey(avID, blockID, keyID, name, 'date', icon, prevID, av.DateDisplayFormatYYYYMMDD) // a valid enum member","handlingStrategy":"validation","validationCode":"const VALID_DATE_FORMATS = await fetchValidDateFormats() // from kernel enum\nif (['date','created','updated'].includes(op.type) && !VALID_DATE_FORMATS.includes(op.format)) {\n  op.format = VALID_DATE_FORMATS[0] // default to a known-good value\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Source date formats from the kernel's enumeration only.","Default to a valid format when the user makes no choice.","Keep frontend and kernel versions aligned."],"tags":["attribute-view","date-format","add-column","validation"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}