README's Laravel/Symfony request examples pass header value arrays; verifyAppHomeReq and verifyWebhookReq throw TypeError

オープン
#31 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php

調査の方向性

Read Headers::normalize() and the verifier paths in src/Internal/Verify/AppHomeReq.php and src/Internal/Verify/BodyHmacInHeader.php; compare their expected header values with the arrays returned by Laravel and Symfony. Check how AdminUIExt, PosUIExt, and NonExchangeableIdToken use Authorization headers. Reproduce both reported TypeErrors, then verify that array-valued headers are handled and scalar headers still produce the expected results.

索引モデルが issue の本文から書いたものです。

説明

devtools-gardener

The "Converting a request" section of the README shows Laravel and Symfony examples that build the request array with $request->headers->all(). Symfony's HeaderBag::all() (which Laravel's request uses too) returns ['name' => ['value', …]], one list of values per header. Headers::normalize() only lowercases the keys, so the verifiers receive arrays where they expect strings:

  • verifyAppHomeReq with an Authorization: Bearer … header (every App Bridge fetch()) throws TypeError: strpos(): Argument #1 ($haystack) must be of type string, array given at src/Internal/Verify/AppHomeReq.php:182.
  • verifyWebhookReq with a correctly signed webhook throws TypeError: hash_equals(): Argument #2 ($user_string) must be of type string, array given in src/Internal/Verify/BodyHmacInHeader.php.

The initial page request works because its ID token is in the query string, so an app that follows the README sees this on its first API call or its first webhook. AdminUIExt, PosUIExt and NonExchangeableIdToken read the Authorization header the same way.

Reproduction with the package alone, v1.0.2 on PHP 8.5 (the same code is on main as of 9 Oct 2026):

$app = new Shopify\App\ShopifyApp(
    clientId: 'test-client-id',
    clientSecret: 'test-client-secret-at-least-32-bytes-long',
);

$app->verifyAppHomeReq([
    'method' => 'GET',
    'headers' => ['authorization' => ['Bearer x.y.z']],
    'url' => 'https://example.test/api/shop',
    'body' => '',
], appHomePatchIdTokenPath: '/auth/patch-id-token');
// TypeError: strpos(): Argument #1 ($haystack) must be of type string, array given

$body = '{"domain":"test-shop.myshopify.com"}';
$hmac = base64_encode(hash_hmac('sha256', $body, 'test-client-secret-at-least-32-bytes-long', true));
$app->verifyWebhookReq([
    'method' => 'POST',
    'headers' => ['x-shopify-hmac-sha256' => [$hmac], 'x-shopify-shop-domain' => ['test-shop.myshopify.com']],
    'url' => 'https://example.test/api/webhooks',
    'body' => $body,
]);
// TypeError: hash_equals(): Argument #2 ($user_string) must be of type string, array given

With string values both calls behave normally (invalid_id_token for the fake token, verified for the webhook).

Two possible fixes: change the README examples to join the values, e.g. array_map(fn ($v) => implode(', ', $v), $request->headers->all()); or have Headers::normalize() accept arrays and join them, which would also cover other frameworks that return value lists. Happy to open a PR for either.

主要言語
PHP
スター
62
フォーク
5
平均マージ
4時間 39分
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Shopify/shopify-app-php のほかの issue

Shopify/shopify-app-php の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。