From 833a7c434f61d39fb1ee29dbba473b0cb391d2c7 Mon Sep 17 00:00:00 2001 From: sshaw Date: Thu, 18 Sep 2025 23:51:08 -0400 Subject: [PATCH] Use ENV.fetch to get HOST instead of relying on useless Sorbet error The auto-generated initializer has various starting time checks to prevent app misconfiguration before running. This did not apply to ShopifyAPI::Context's host: keyword. If the HOST env var was not present, a unhelpful "TypeError (Passed `nil` into T.must)" error was raised by Sorbet. Now if there is no HOST env var present, the app will fail to run, like it does with other checks, and the user will receive a helpful message. --- lib/generators/shopify_app/install/templates/shopify_app.rb.tt | 2 +- test/generators/install_generator_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/generators/shopify_app/install/templates/shopify_app.rb.tt b/lib/generators/shopify_app/install/templates/shopify_app.rb.tt index a1ba381b1..9265cd8d8 100644 --- a/lib/generators/shopify_app/install/templates/shopify_app.rb.tt +++ b/lib/generators/shopify_app/install/templates/shopify_app.rb.tt @@ -47,7 +47,7 @@ Rails.application.config.after_initialize do api_key: ShopifyApp.configuration.api_key, api_secret_key: ShopifyApp.configuration.secret, api_version: ShopifyApp.configuration.api_version, - host: ENV['HOST'], + host: ENV.fetch('HOST'), scope: ShopifyApp.configuration.scope, is_private: !ENV.fetch('SHOPIFY_APP_PRIVATE_SHOP', '').empty?, is_embedded: ShopifyApp.configuration.embedded_app, diff --git a/test/generators/install_generator_test.rb b/test/generators/install_generator_test.rb index c2224ccc3..248c5ea82 100644 --- a/test/generators/install_generator_test.rb +++ b/test/generators/install_generator_test.rb @@ -33,7 +33,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase api_key: ShopifyApp.configuration.api_key, api_secret_key: ShopifyApp.configuration.secret, api_version: ShopifyApp.configuration.api_version, - host: ENV['HOST'], + host: ENV.fetch('HOST'), scope: ShopifyApp.configuration.scope, is_private: !ENV.fetch('SHOPIFY_APP_PRIVATE_SHOP', '').empty?, is_embedded: ShopifyApp.configuration.embedded_app,