There is no config schema for the `value` property of `datetime` fields

Created on 17 June 2025, 3 months ago

Problem/Motivation

As you know, Bob, it's possible to store static default field values in field_config entities.

Except for datetime fields. Why? Because there is no config schema defined for date fields' value property. If strict config schema checking is enabled, you'll get an exception when you try to save a date field with a default value in config, even if that value is valid.

Steps to reproduce

Enable strict config schema -- like in a test -- and try to create a datetime field with a default value. Any default value.

Proposed resolution

The correct fix here is to add validation for the default value of date fields! But they're complicated and somewhat polymorphic, so that could take a while to get right.

So, this issue proposes the quick fix -- add the following to the field.value.datetime schema type:

value:
  type: ignore

This has the benefit of getting rid of the config schema error in the short term, while not making the status quo any worse (it's already possible to store an invalid default value, since it's not validated anyway). The catch is that the schema type should not be marked as FullyValidatable until the value actually has real constraints that will catch invalid values.

User interface changes

Should not affect the UI at all.

API changes

None really.

Data model changes

Date fields' default values, as stored in config, will be defined as ignored.

Release notes snippet

TBD

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

datetime.module

Created by

πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024