Upgrading to 10.1.0 from an older Ruby command-line script that interacts with my private Shopify store. Worked fine in previous versions for many years before the new Context mechanism.
Error:
/usr/local/lib/ruby/gems/3.1.0/gems/shopify_api-10.1.0/lib/shopify_api/utils/session_utils.rb:71:in `load_private_session': Could not load private shop, Context.private_shop is nil. (ShopifyAPI::Errors::SessionNotFoundError)
from /usr/local/lib/ruby/gems/3.1.0/gems/sorbet-runtime-0.5.10109/lib/types/private/methods/call_validation.rb:161:in `bind_call'
from /usr/local/lib/ruby/gems/3.1.0/gems/sorbet-runtime-0.5.10109/lib/types/private/methods/call_validation.rb:161:in `validate_call'
from /usr/local/lib/ruby/gems/3.1.0/gems/sorbet-runtime-0.5.10109/lib/types/private/methods/_methods.rb:270:in `block in _on_method_added'
from /usr/local/lib/ruby/gems/3.1.0/gems/shopify_api-10.1.0/lib/shopify_api/utils/session_utils.rb:20:in `load_current_session'
from /usr/local/lib/ruby/gems/3.1.0/gems/sorbet-runtime-0.5.10109/lib/types/private/methods/call_validation.rb:161:in `bind_call'
from /usr/local/lib/ruby/gems/3.1.0/gems/sorbet-runtime-0.5.10109/lib/types/private/methods/call_validation.rb:161:in `validate_call'
from /usr/local/lib/ruby/gems/3.1.0/gems/sorbet-runtime-0.5.10109/lib/types/private/methods/_methods.rb:270:in `block in _on_method_added'
from /usr/local/lib/ruby/gems/3.1.0/gems/shopify_api-10.1.0/lib/shopify_api/context.rb:137:in `active_session'
from /usr/local/lib/ruby/gems/3.1.0/gems/sorbet-runtime-0.5.10109/lib/types/private/methods/call_validation.rb:161:in `bind_call'
from /usr/local/lib/ruby/gems/3.1.0/gems/sorbet-runtime-0.5.10109/lib/types/private/methods/call_validation.rb:161:in `validate_call'
from /usr/local/lib/ruby/gems/3.1.0/gems/sorbet-runtime-0.5.10109/lib/types/private/methods/_methods.rb:270:in `block in _on_method_added'
from /usr/local/lib/ruby/gems/3.1.0/gems/shopify_api-10.1.0/lib/shopify_api/rest/resources/2022_01/order.rb:381:in `count'
from /usr/local/lib/ruby/gems/3.1.0/gems/sorbet-runtime-0.5.10109/lib/types/private/methods/call_validation.rb:161:in `bind_call'
from /usr/local/lib/ruby/gems/3.1.0/gems/sorbet-runtime-0.5.10109/lib/types/private/methods/call_validation.rb:161:in `validate_call'
from /usr/local/lib/ruby/gems/3.1.0/gems/sorbet-runtime-0.5.10109/lib/types/private/methods/_methods.rb:270:in `block in _on_method_added'
from /Users/ryan/Code/site-tools/shopify/site-shared.rb:229:in `load_open_shopify_orders'
from ./submit-orders:396:in `
Ruby code:
```ruby
shopify_host = get_secret_key('Shopify', 'SHOPIFY_HOST')
shopify_url = "https://" + shopify_host + "/"
api_key = get_secret_key('Shopify', 'SHOPIFY_API_KEY')
api_secret = get_secret_key('Shopify', 'SHOPIFY_API_SECRET')
print("Connecting to " + shopify_host + "\n")
test = ShopifyAPI::Context.setup(
host_name: shopify_host,
api_key: api_key,
api_secret_key: api_secret,
scope: "read_orders,read_products",
is_private: true,
is_embedded: false,
api_version: "2022-01",
session_storage: ShopifyAPI::Auth::FileSessionStorage.new
)
print(test)
It is a complete mystery as I’ve read the docs several times over the last few days (taking breaks), tried different code changes, etc. There is no useful info that I can glean from the error messages. The printing of the value of the Context is T::Private::Types::Void::VOID.
Any idea what I might be missing? Accessing the complete URL with curl on the command line works fine (at least using the API password instead of the API shared secret), for example:
curl https://$SHOPIFY_API_KEY:$SHOPIFY_API_PW@$SHOPIFY_HOST/admin/api/2022-04/products.json
Thank you for any leads! This is all called on startup of various Ruby scripts that interact with my Shopify store.