diff --git a/cookiebot.install b/cookiebot.install
index a7f9c4cb188c8901107566b71518eabf8a707623..18dd7b3c3797f4191c7cd63d2541291241cf8c37 100644
--- a/cookiebot.install
+++ b/cookiebot.install
@@ -41,6 +41,11 @@ function cookiebot_update_8003() {
 
   $path = \Drupal::service('path_alias.manager')->getPathByAlias($declaration_node_path);
   preg_match('/node\/(\d+)/', $path, $matches);
+
+  // Exit if we have no matches.
+  if (empty($matches) || empty($matches[1])) {
+    return;
+  }
   $node = \Drupal::entityTypeManager()->getStorage('node')->load($matches[1]);
   $config->set('cookiebot_show_declaration_node', $node->id());
   $config->clear('cookiebot_show_declaration_node_path');