siyuan-note/siyuan · error
invalid date display format
Error message
invalid date display format
What it means
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.
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
Example fix
// before addAttrViewKey(avID, keyID, name, "date", "", "YYYY-MM-DD") // after addAttrViewKey(avID, keyID, name, "date", "", "20060102") // a valid DateDisplayFormat value
Defensive patterns
Strategy: validation
Validate before calling
const VALID_DATE_FORMATS = [/* av.DateDisplayFormat values, see petal typings */];
if (isDateType && !VALID_DATE_FORMATS.includes(dateFormat)) throw new Error(`invalid date display format: ${dateFormat}`); Type guard
type DateDisplayFormat = typeof VALID_DATE_FORMATS[number]; const isDateFormat = (s: string): s is DateDisplayFormat => VALID_DATE_FORMATS.includes(s);
Try / catch
try { await addAttrViewKey(...); } catch (e) { if (String(e).includes("invalid date display format")) { /* retry with default format */ } else throw e; } Prevention
- 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
When it happens
Trigger: Calling add-attribute-view-key with type "date"/"created"/"updated" and a dateFormat parameter not matching any valid DateDisplayFormat enum value.
Common situations: 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.
Related errors
- at least one visible view is required
- attribute view custom color index
- attribute view custom color must not be null
- attribute view custom colors count exceeds the
- attribute view custom colors must not be empty
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/412193756e83b0b2.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/attribute_view.go:7484
return
}
func newAttributeViewKey(keyID, keyName, keyType, keyIcon string, dateFormat av.DateDisplayFormat) (ret *av.Key, err error) {
keyTyp := av.KeyType(keyType)
switch keyTyp {
case av.KeyTypeBlock:
return nil, errors.New("cannot add an attribute view block key")
case av.KeyTypeText, av.KeyTypeNumber, av.KeyTypeDate, av.KeyTypeSelect, av.KeyTypeMSelect, av.KeyTypeURL, av.KeyTypeEmail,
av.KeyTypePhone, av.KeyTypeMAsset, av.KeyTypeTemplate, av.KeyTypeCreated, av.KeyTypeUpdated, av.KeyTypeCheckbox,
av.KeyTypeRelation, av.KeyTypeRollup, av.KeyTypeLineNumber:
default:
return nil, fmt.Errorf("unsupported attribute view key type [%s]", keyType)
}
ret = av.NewKey(keyID, keyName, filterAttrViewIconValue(keyIcon), keyTyp)
if av.KeyTypeDate == keyTyp || av.KeyTypeCreated == keyTyp || av.KeyTypeUpdated == keyTyp {
if !dateFormat.IsValid() {
return nil, errors.New("invalid date display format")
}
ret.DateFormat = dateFormat
}
if av.KeyTypeRollup == keyTyp {
ret.Rollup = &av.Rollup{Calc: &av.RollupCalc{Operator: av.CalcOperatorNone}}
}
return
}
func addAttributeViewKey(attrView *av.AttributeView, currentView *av.View, key *av.Key, previousKeyID string) {
attrView.KeyValues = append(attrView.KeyValues, &av.KeyValues{Key: key})
for _, view := range attrView.Views {
newField := &av.BaseField{ID: key.ID}
if nil != view.Table {
newField.Wrap = view.Table.WrapField
if "" == previousKeyID {View on GitHub (pinned to 9f775e8a12)