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:

  • NULL is 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 NULL to '',
  • 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:

  1. Schema definitions for these properties should declare them as non-nullable string types.
  2. Empty values should remain ''; no forced conversion to NULL.
  3. If a module passes NULL internally, getters should normalize it to an empty string (e.g., $value ?? '').
  4. 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 NULL adds no practical value.

This policy formalizes a more pragmatic, UI-aligned, and DX-friendly approach to text configuration values in Drupal core.

Comments

bbrala created an issue. See original summary.

bbrala’s picture

Issue summary: View changes
bbrala’s picture

Issue summary: View changes
bbrala’s picture

Issue tags: +validation, +Config validation

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.