diff --git a/core/lib/Drupal/Core/Config/Plugin/Validation/Constraint/ConfigExistsConstraintValidator.php b/core/lib/Drupal/Core/Config/Plugin/Validation/Constraint/ConfigExistsConstraintValidator.php
index 590a3056a110eb7b56674ba1def000eae3d97826..83067c2c1b59339e33e325eac18cc68a7ad30d44 100644
--- a/core/lib/Drupal/Core/Config/Plugin/Validation/Constraint/ConfigExistsConstraintValidator.php
+++ b/core/lib/Drupal/Core/Config/Plugin/Validation/Constraint/ConfigExistsConstraintValidator.php
@@ -43,6 +43,11 @@ public static function create(ContainerInterface $container) {
    * {@inheritdoc}
    */
   public function validate(mixed $name, Constraint $constraint) {
+    // This constraint may be used to validate nullable (optional) values.
+    if ($name === NULL) {
+      return;
+    }
+
     if (!in_array($name, $this->configFactory->listAll(), TRUE)) {
       $this->context->addViolation($constraint->message, ['@name' => $name]);
     }
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigExistsConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigExistsConstraintValidatorTest.php
index 03992fd9c92180d5906a921169657de3198526d1..bb94ae83d7955040dc8d56fb272ab701a53fb54e 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigExistsConstraintValidatorTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigExistsConstraintValidatorTest.php
@@ -40,6 +40,10 @@ public function testValidation(): void {
 
     $this->installConfig('system');
     $this->assertCount(0, $data->validate());
+
+    // NULL should not trigger a validation error: a value may be nullable.
+    $data->setValue(NULL);
+    $this->assertCount(0, $data->validate());
   }
 
 }