Kyon147 / laravel-shopify

A full-featured Laravel package for aiding in Shopify App development
MIT License
331 stars 98 forks source link

MissingAuthUrlException triggered when installing the app on a store with no theme #305

Closed ajprod closed 3 weeks ago

ajprod commented 2 months ago

Expected Behavior

App should be installed normally with no error

Current Behavior

On installation on a new store with no theme, the MissingAuthUrlException is triggered

Failure Information

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Create a new development store (a few weeks ago, Shopify made a change where new development stores don't have a theme installed)
  2. Install an app through your partners dashboard
  3. MissingAuthUrlException is triggered

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

Failure Logs

[2024-04-30 07:30:51] local.ERROR: Missing auth url {"userId":1234,"exception":"[object] (Osiset\\ShopifyApp\\Exceptions\\MissingAuthUrlException(code: 0): Missing auth url at /my-app/vendor/kyon147/laravel-shopify/src/Traits/AuthController.php:55)

sunnyvaniya21 commented 2 months ago

@Kyon147 can you please look into this issue ?

Kyon147 commented 2 months ago

@sunnyvaniya21 this is likely due to the theme level check that happens, it might need to be tweaked to now not expect being able to find the theme level.

It's likely here or around here that needs debugging https://github.com/Kyon147/laravel-shopify/blob/master/src/Services/ThemeHelper.php#L109

ClementBolard commented 2 months ago

The error come from the extractStoreMainTheme in the ThemeHelper. Indeed, Shopify return an empty array of themes.

As a quick fix, you can add a try catch around the call of the Theme Support Level function in the InstallShop.php file in Actions.

try{
     $themeSupportLevel = call_user_func($this->verifyThemeSupport, $shop->getId());
     $this->shopCommand->setThemeSupportLevel($shop->getId(), ThemeSupportLevel::fromNative($themeSupportLevel));
}catch(Exception $e){
     $themeSupportLevel = null;
}
Kyon147 commented 1 month ago

312 adds in your suggestion but have created a new enum for the value for null to keep things consistent