Overview/summary
As well as many others I often get the following error too:
TypeError: Shopify\Utils::sanitizeShopDomain(): Argument #1 ($shop) must be of type string, null given, called in /app/app/Lib/AuthRedirection.php on line 17 in file /app/vendor/shopify/shopify-api/src/Utils.php on line 36
It occurs when the webserver gets a malformed call (without the shop parameter basically), and this may happen for many reasons.
(In my opinion this looks more like a bug then an enhancement, but the application still works even if the log files gets filled with plenty of lines of this error)
Motivation
The function Shopify\Utils::sanitizeShopDomain should be called either with an empty string as fallback for its first parameter: Utils::sanitizeShopDomain($request->query("shop", '')) like HERE,
or with a guard on the first parameter: $shop = $request->query('shop') ? Utils::sanitizeShopDomain($request->query('shop')) : null; like HERE
(Then the code should deal with the case $shop = null of course), otherwise it throws a TypeError exception because $request->query('shop') returns null and not a string (as requested by the signature of Utils::sanitizeShopDomain) if the shop variable is missing from the query params.
Relevant lines in the code: