Error when trying to fetch webhooks list in Shopify App

Topic summary

A developer is building a custom Shopify app in PHP using Shopify’s official PHP library to receive order information via webhooks and forward it to a third party.

Current Status:

  • App initialization completed successfully
  • Error occurs when attempting to fetch the current webhooks list

Error Details:

  • TypeError in Shopify\Utils::loadCurrentSession()
  • The method expects an array as argument 1 but receives null instead
  • Error originates from Utils.php line 158

Code Context:
The developer’s code shows:

  • Proper initialization with Context, API keys, scopes, and FileSessionStorage
  • Attempt to load current session using Utils::loadCurrentSession() with request headers, cookies, and online session parameters
  • Subsequent webhook fetch attempt using Webhook::all()

The issue appears to stem from passing null values to loadCurrentSession(), suggesting missing or improperly formatted session data. The developer is seeking help understanding why this error occurs.

Summarized with AI on November 23. AI used: claude-sonnet-4-5-20250929.

We are building our own custom app for the purpose of getting order information via orders webhook and then sending that order to a third party.
We are building it in PHP using Shopify’s own PHP library
We have successfully initialized.
However when we try to fetch current webhooks, we get this error:

Fatal error: Uncaught TypeError: Argument 1 passed to Shopify\Utils::loadCurrentSession() must be of the type array, null given, called in /www/doc/www.example.com/www/script/index.php on line 45 and defined in /www/doc/www.example.com/www/script/vendor/shopify/shopify-api/src/Utils.php:158 Stack trace: #0 /www/doc/www.example.com/www/script/index.php(45): Shopify\Utils::loadCurrentSession(NULL, NULL, NULL) #1 {main} thrown in /www/doc/www.example.com/www/script/vendor/shopify/shopify-api/src/Utils.php on line 158

By looking at our code below, can you tell us why this error occurs?

<?php

require("vendor/autoload.php");

use Shopify\Auth\FileSessionStorage;
use Shopify\Auth\Session;
use Shopify\Rest\Admin2022_10\Customer;
use Shopify\Rest\Admin2022_10\Webhookv2;
use Shopify\Utils;

Shopify\Context::initialize(
    'apiKey',
    'apiSecretKey',
    'read_analytics, read_assigned_fulfillment_orders, read_customers, read_draft_orders, read_merchant_managed_fulfillment_orders, read_order_edits, read_orders, read_script_tags, read_third_party_fulfillment_orders',
    'https://sozialstar.de/script/',
    new FileSessionStorage('/tmp/php_sessions'),
    '2022-10',
);

$this->test_session = Utils::loadCurrentSession(
    $requestHeaders,
    $requestCookies,
    $isOnline
);
Webhookv2::webhooks(
    $this->test_session, // Session
    [], // Url Ids
    [], // Params
);

?>