fix: Handle nil processed_params for WhatsApp templates without params (#12177)

WhatsApp templates without parameters (body-only templates like
notifications, confirmations) were failing to send with the error:
ArgumentError (Unknown legacy format: NilClass). This affected all
parameter-less templates across marketing messages, notifications, and
utility templates.
This commit is contained in:
Muhsin Keloth
2025-08-12 22:56:53 +05:30
committed by GitHub
parent 469e724e3a
commit 48fa7bf72b
3 changed files with 84 additions and 0 deletions

View File

@@ -86,6 +86,9 @@ class Whatsapp::TemplateParameterConverterService
# Hash format: {"1": "John", "name": "Jane"} → {body: {"1": "John", "name": "Jane"}}
body_params = convert_hash_to_body_params(legacy_params)
enhanced['body'] = body_params unless body_params.empty?
when NilClass
# Templates without parameters (nil processed_params)
# Return empty enhanced structure
else
raise ArgumentError, "Unknown legacy format: #{legacy_params.class}"
end