From e4ab2a0d2433d96c450fc754b9d83de28dc16e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Wn=C4=99trzak?= Date: Tue, 5 Nov 2024 14:41:40 +0100 Subject: [PATCH] Improve error on unknown role in accessories config. Previously when unknown role (or with typo) was placed in accessories.roles, this error was thrown: `ERROR (NoMethodError): undefined method `hosts' for nil`. --- lib/kamal/configuration/accessory.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/kamal/configuration/accessory.rb b/lib/kamal/configuration/accessory.rb index 3258c9d09..aeb5f334f 100644 --- a/lib/kamal/configuration/accessory.rb +++ b/lib/kamal/configuration/accessory.rb @@ -176,7 +176,9 @@ def hosts_from_hosts def hosts_from_roles if accessory_config.key?("roles") - accessory_config["roles"].flat_map { |role| config.role(role).hosts } + accessory_config["roles"].flat_map do |role| + config.role(role)&.hosts || raise(Kamal::ConfigurationError, "Unknown role in accessories config: '#{role}'") + end end end