Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.5.1 is a breaking change: CookieNotFoundException #350

Open
1 task done
bradsk88 opened this issue Jun 25, 2024 · 3 comments
Open
1 task done

5.5.1 is a breaking change: CookieNotFoundException #350

bradsk88 opened this issue Jun 25, 2024 · 3 comments

Comments

@bradsk88
Copy link

bradsk88 commented Jun 25, 2024

Issue summary

I'm working a large Laravel project which makes use of this library.
After updating from 5.5.0 → 5.5.1 my test suites began to fail with a CookieNotFoundException.

Expected behavior

Either:

  1. My code should continue to function, or ...
  2. The SDK version should be bumped to indicate a breaking change and provide recommendations for how to overcome the breakage, or...
  3. The change introduced in 5.5.1 should be rolled back

Actual behavior

We are unable to update this SDK without doing a deep investigation to understand the source of the exception.

Steps to reproduce the problem

To be honest, I'm a bit new to the project, so I was not able to strip away all the details and produce a sharable reproduction (though I tried 😄)

However, I can share this code, which ran without error in version 5.5.0 but now throws a CookieNotFoundException

<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Lib\CookieHandler;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Log;
use Shopify\Auth\OAuth;
use Shopify\Utils;
use Shopify\Webhooks\Registry;
use Shopify\Webhooks\Topics;

class ShopifyController extends Controller
{
    public function callback(Request $request): RedirectResponse
    {
        $session = OAuth::callback( // <------------------ This is the line which now raises an exception
            (array) $request->cookie(),
            (array) $request->query(),
            [CookieHandler::class, 'saveShopifyCookie'],
        );

        $host = strval($request->query('host'));
        $shop = Utils::sanitizeShopDomain(strval($request->query('shop')));

        abort_if(is_null($shop), Response::HTTP_BAD_REQUEST);

        $response = Registry::register(
            '/api/webhooks',
            Topics::APP_UNINSTALLED,
            $shop,
            $session->getAccessToken() ?? '',
        );
        if ($response->isSuccess()) {
            Log::debug("Registered APP_UNINSTALLED webhook for shop $shop");
        } else {
            Log::error(
                "Failed to register APP_UNINSTALLED webhook for shop $shop with response body: " .
                print_r($response->getBody(), true)
            );
        }

        return redirect(Utils::getEmbeddedAppUrl($host));
    }
}

Checklist

  • I have described this issue in a way that is actionable (if possible)
@Kudze
Copy link

Kudze commented Jul 1, 2024

Could it be that you're experiencing this issue: #352?

@ConstantBqt
Copy link

Did you manage to find what to fix in your code ?
I faced the same issue and I had to rollback to 5.5.0

@paulomarg
Copy link
Contributor

Hey folks, sorry you're having issues. We'll investigate what might have changed in 5.5.1, thanks for pinning it down to that version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants