I recently updated my Shopify Rails application with some new features and code changes. The deployment process works perfectly and the app starts up without any issues. However, when I try to access any controller like the dashboard_controller or other routes, the application throws an error page.
Here’s what I’m seeing in the logs:
I,[2024-03-13T17:56:17.131281 #2] INFO -- : [ ShopifyApp | INFO | Shop Not Found ] Installed store - my-store.myshopify.com deduced from user session
F, [2024-03-13T17:56:17.131699 #2] FATAL -- : [abc123-def4-5678-9012-fedcba654321]
TypeError (Passed `nil` into T.must):
sorbet-runtime (0.5.11292) lib/types/_types.rb:222:in `must'
shopify_api (14.0.1) lib/shopify_api/context.rb:173:in `host_scheme'
sorbet-runtime (0.5.11292) lib/types/private/methods/call_validation_2_7.rb:59:in `bind_call'
The error points to a nil value being passed to T.must but I’m struggling to identify where this nil value originates from. I’ve attempted switching Ruby versions and updating the Sorbet gem but the issue persists. Any ideas on how to debug this T.must error in the Shopify API context?
your shopify context isn’t initializing properly. i ran into the same thing - turns out the host wasn’t getting set right between dev and production environments. add some debug logging to your context setup so you can see what values you’re actually getting. also double-check your webhook urls since those can screw up host detection.
I hit the same T.must TypeError after upgrading to shopify_api 14.x. It turned out that the host configuration wasn’t set properly in ShopifyAPI::Context. The host_scheme method was trying to access a config value that wasn’t initialized during app startup. Check your shopify_app.rb initializer to ensure the host parameter has the correct scheme (https). You should also verify that your APP_URL environment variable includes the protocol. I ended up manually setting the host config in my initializer instead of relying on auto-detection, which resolved the nil value issue passed to T.must. This problem typically occurs when the context cannot determine the host scheme due to an invalid host configuration.
Same thing happened when I upgraded shopify_api. Your host value is probably getting passed as nil to the Shopify context. I had to add explicit nil checks in my application controller before calling any Shopify API methods. Turns out my production environment wasn’t setting the host scheme config properly during Rails boot. Add some logging right before the context initializes to see what your host value actually is. My deployment worked fine, but the runtime config didn’t match what the Shopify gem expected. The T.must validation failed because it got nil instead of a proper host string.