Problem/Motivation
Drupal core currently treats empty strings ('') in configuration as undesirable and encourages converting them to NULL. This convention was introduced inconsistently over time and has resulted in:
- unnecessary upgrade paths,
- brittle or non-functional hooks created solely to modify shipped configuration,
- extensive repetitive test changes,
- awkward developer experience in getters and validation,
- UI/API inconsistencies because forms only produce strings.
Recent issues (e.g., #3445150: Add validation constraints to core.entity_view_mode.*.* and #3533291: file_file_video_presave() attempts to update shipped configuration but doesn't work) demonstrate that enforcing '' → NULL provides little functional benefit but creates significant maintenance overhead. Several maintainers (@berdir, @longwave, @phenaproxima, @bbrala) agree that:
NULLis not meaningfully better than an empty string for description or similar text fields,- browsers and forms cannot operate on
NULL, only strings, - API getters already normalize
NULLto'', - distinguishing between “unset” and “empty” rarely matters for string config values,
- enforcing this rule creates churn and complexity without user-facing value.
In short: forcing empty strings to become NULL causes more problems than it solves.
Proposed Policy
For configuration properties that:
- store text,
- do not need to differentiate between “unset” and “empty”, and
- have no semantic requirement for
NULL,
we should treat them as non-nullable strings.
The concrete implications:
- Schema definitions for these properties should declare them as non-nullable string types.
- Empty values should remain
''; no forced conversion toNULL. - If a module passes
NULLinternally, getters should normalize it to an empty string (e.g.,$value ?? ''). - No upgrade paths should be required solely to convert
'' → NULL.
Benefits
- Eliminates unnecessary config-update hooks and deprecation notices,
- Removes upgrade paths that exist only for canonicalization,
- Reduces test churn and validation boilerplate,
- Provides consistent APIs that always return strings,
- Aligns behavior with how browsers and forms work,
- Reflects current maintainer consensus that forcing
NULLadds no practical value.
This policy formalizes a more pragmatic, UI-aligned, and DX-friendly approach to text configuration values in Drupal core.
Comments
Comment #2
bbralaComment #3
bbralaComment #4
bbrala