Shopify / shopify-app-template-remix

316 stars 131 forks source link

Shopify Deploy error on new relative URLs in declarative Webhooks in shopify.app.toml #776

Closed muchisx closed 1 month ago

muchisx commented 1 month ago

Issue summary

Before opening this issue, I have:

Expected behavior

The relative URL should work before being added to the remix template (This is probably an issue with the cli, or the @shopify/app package?

Actual behavior

Declaring a webhook subscript as such:

https://github.com/Shopify/shopify-app-template-remix/blob/ef188ef9616c62785168a5759b2d0b60a0da6086/shopify.app.toml#L8-L10

And then running npm run deploy throws an error such as:

  App configuration is not valid                                                        │
│  Validation errors in shopify.app.nuflorist-dev-delta.toml:                            │
│                                                                                        │
│  • [webhooks.subscriptions.0.uri]: URI isn't correct URI format of https://,           │
│  pubsub://{project}:topic or Eventbridge ARN      

Here's my entire shopify.app.toml aswell:

# Learn more about configuring your app at https://shopify.dev/docs/apps/tools/cli/configuration

client_id = "xxxxxxxxxxxxxxxxxxx"
name = "xxxxxxxxxxxxxxxxxx"
handle = "xxxxxxxxxxxxxxxxxx"
application_url = "xxxxxxxxxxxxxxxx.trycloudflare.com"
embedded = true

[build]
automatically_update_urls_on_dev = true
dev_store_url = "xxxxxxxxxxxxxxxxxx.myshopify.com"

[access_scopes]
# Learn more at https://shopify.dev/docs/apps/tools/cli/configuration#access_scopes
scopes = "read_metaobject_definitions,read_metaobjects,read_products,read_shipping,write_metaobject_definitions,write_metaobjects"

[auth]
redirect_urls = [
  "xxxxxxxxxxxxxxxx.trycloudflare.com/auth/callback",
  "xxxxxxxxxxxxxxxx.trycloudflare.com/auth/shopify/callback",
  "xxxxxxxxxxxxxxxx.trycloudflare.com/api/auth/callback"
]

[webhooks]
api_version = "2024-04"

  [[webhooks.subscriptions]]
  topics = [ "app/uninstalled" ]
  uri = "/webhooks"

  [[webhooks.subscriptions]]
  uri = "https://xxxxxxxxxxxxxxxxxxx.com/webhooks"
  compliance_topics = [ "customers/data_request", "customers/redact", "shop/redact" ]

[app_proxy]
url = "xxxxxxxxxxxxxxxx.trycloudflare.com/api/proxy"
subpath = "xxxxxxx"
prefix = "apps"

[pos]
embedded = false

Steps to reproduce the problem

  1. Same as above
ccarlosm commented 1 month ago

You could try restoring app configuration from the Partner Dashboard with: "npm run shopify app config link"

paulomarg commented 1 month ago

In addition to what @ccarlosm suggested, could you please confirm whether running shopify app dev before deploying fixes it?

There might be an issue with the webhook declaration if you haven't assigned a "proper" URL to your app by running dev before.

Hope this helps!

RivermintGlenn commented 1 month ago

@paulomarg

I am also getting this error when using a relative URI.

I am confused with how to implement in development with an automatically updated cloudflare url. The docs specifically mention to use a relative uri:

| In this case, leverage Shopify's support of relative paths for the URI: uri = "/webhooks"

Error

|  App configuration is not valid                                              
│  Validation errors in shopify.app.toml:                                      
│                                                                              
│  • [webhooks.subscriptions.0.uri]: URI isn't correct URI format of           
│  https://, pubsub://{project}:topic or Eventbridge ARN    

Code

[[webhooks.subscriptions]]
uri = "/api/webhooks"
compliance_topics = [
  "customers/data_request",
  "customers/redact",
  "shop/redact",
]

Can you provide some clarity on how to work with HTTPS webhooks in development?

paulomarg commented 1 month ago

I just ran an app using this config:

[webhooks]
api_version = "2024-01"

  [[webhooks.subscriptions]]
  topics = [ "app/uninstalled" ]
  uri = "/webhooks"
  compliance_topics = [ "customers/data_request", "customers/redact", "shop/redact" ]

and it works as expected. Can you please confirm whether you're using the latest version of the CLI? I was using 3.64.1.

RivermintGlenn commented 1 month ago

🙏 🙏 🙏

Updating my CLI fixed the issue. Thank you for the assistance @paulomarg.

It's appreciated!!

mariusbolstad commented 1 month ago

I had the same problem with "shopify app deploy" and it was fixed after I upgraded the CLI. However when I run "npm run dev" I get the same error message again complaining about URI on the wrong format. Any solutions for this problem?

Edit: "shopify app dev" solved it

Made4Uo commented 1 month ago
 [[webhooks.subscriptions]]
  topics = [ "app/uninstalled" ]
  uri = "/webhooks"
  compliance_topics = [ "customers/data_request", "customers/redact", "shop/redact" ]

This works with me. Thank you

paulomarg commented 1 month ago

It sounds like this was working for pretty much everyone once they updated the CLI, so I'm going to go ahead and close this issue. Please let us know if you still have problems!

DuyHiepVP2003 commented 4 weeks ago

I just ran an app using this config:

[webhooks]
api_version = "2024-01"

  [[webhooks.subscriptions]]
  topics = [ "app/uninstalled" ]
  uri = "/webhooks"
  compliance_topics = [ "customers/data_request", "customers/redact", "shop/redact" ]

and it works as expected. Can you please confirm whether you're using the latest version of the CLI? I was using 3.64.1.

I have tried this setup. After running npm run dev, my TOML file becomes: [[webhooks.subscriptions]] uri = "webhooks" compliance_topics = [ "customers/data_request", "customers/redact", "shop/redact" ] and I still encounter the error. My shopify cli version is 3.64.1

gonzaloriestra commented 4 weeks ago

@DuyHiepVP2003 that's a bug in the CLI, it should be fixed here and hopefully included in the next release this week.

As a workaround, you can replace the uri in your TOML from webhooks to /webhooks.