Skip to content

Allow kafka:// URIs in webhook subscription TOML validation#7817

Merged
dpeacock merged 1 commit into
mainfrom
add-kafka-webhook-uri-validation
Jun 22, 2026
Merged

Allow kafka:// URIs in webhook subscription TOML validation#7817
dpeacock merged 1 commit into
mainfrom
add-kafka-webhook-uri-validation

Conversation

@dpeacock

@dpeacock dpeacock commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

The webhook subscription URI validator (WebhookSubscriptionUriValidation in common.ts) only accepted relative paths, HTTPS URLs, pubsub:// URIs, and Eventbridge ARNs. kafka:// URIs were rejected at TOML validation time, which blocked the internal Shopify apps that currently rely on Kafka delivery (Email, Shop, Flow, etc.) from adopting declarative webhooks.

What is this change?

  • Add a kafka://{topic} regex to common.ts. The topic character set ([a-zA-Z0-9_.-]+) mirrors the server-side validator so the CLI rejects exactly what the platform rejects on shape.
  • Include kafkaRegex.test(uri) in the .refine() predicate and update the error message to mention kafka://{topic-id}.
  • Add tests covering: accepting a well-formed kafka://my_topic.name-1 URI; rejecting kafka://invalid topic!; and including kafka in the combined-URI subscriptions test (whose expansion sorts alphabetically by URI: arn → https → kafka → pubsub).
  • Update the 3 places in loader.test.ts that assert the previous error string to include kafka://{topic-id}.

Authorization is enforced server-side, not in the CLI

The CLI validates URI shape only. Internal-app-only enforcement happens at the platform: webhook_uri_validator.rb#validate_kafka_topic checks record.api_client.internal_graphql_access? and returns "uses delivery method 'kafka' and is not supported" for non-internal clients. This mirrors how pubsub:// and Eventbridge ARNs are validated today — the CLI doesn't reproduce server authorization rules, it only filters obviously malformed input.

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows) — pure TS regex, no platform-specific code.
  • I've considered possible documentation changes — added a changeset; no user-facing docs reference the old error string.

Copilot AI review requested due to automatic review settings June 15, 2026 19:04
@dpeacock dpeacock requested review from a team as code owners June 15, 2026 19:04
@github-actions github-actions Bot added the Area: @shopify/app @shopify/app package issues label Jun 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Shopify CLI webhook TOML validation to accept Kafka delivery URIs, unblocking internal apps that use Kafka from adopting declarative webhooks.

Changes:

  • Added kafka://{topic} shape support to WebhookSubscriptionUriValidation and updated the validation error message to mention Kafka.
  • Updated/added tests to cover valid/invalid Kafka URIs and included Kafka in the combined-URI sorting/expansion test.
  • Added a changeset to publish the validation update as a patch release for @shopify/app.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
packages/app/src/cli/models/extensions/specifications/validation/common.ts Adds a Kafka URI regex and allows kafka://... in the webhook subscription URI validator + updates the error message.
packages/app/src/cli/models/app/loader.test.ts Updates expected validation error strings and adds Kafka URI test coverage (including combined-URI expansion order).
.changeset/add-kafka-webhook-uri-validation.md Announces the patch release and describes the new Kafka URI validation behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/app/src/cli/models/app/loader.test.ts
Comment thread packages/app/src/cli/models/app/loader.test.ts
Comment thread .changeset/add-kafka-webhook-uri-validation.md Outdated
@dpeacock dpeacock force-pushed the add-kafka-webhook-uri-validation branch from 14cd554 to 4c7f7ae Compare June 15, 2026 19:11
@dpeacock dpeacock marked this pull request as draft June 15, 2026 19:12
@dpeacock dpeacock force-pushed the add-kafka-webhook-uri-validation branch from 4c7f7ae to 8831353 Compare June 18, 2026 00:29
@github-actions github-actions Bot added Area: @shopify/cli @shopify/cli package issues and removed Area: @shopify/app @shopify/app package issues labels Jun 18, 2026
@dpeacock dpeacock marked this pull request as ready for review June 19, 2026 01:16
@dpeacock dpeacock requested review from a team and karenxie June 19, 2026 01:16
@dpeacock dpeacock requested a review from a team June 19, 2026 02:05
The webhook subscription URI validator in @shopify/app previously rejected
kafka:// URIs, which blocked internal Shopify apps (Email, Shop, Flow,
Collabs, Stocky, Marketplace, Collective, etc.) from declaring their
webhook subscriptions in the app TOML.

Adds a kafka:// regex mirroring the server-side topic character set
([a-zA-Z0-9_.-]+) so the CLI rejects exactly what the platform rejects
for shape. Authorization (internal-app-only) is enforced by the platform
at subscription creation time via api_client.internal_graphql_access?;
the CLI intentionally validates URI shape only, matching how pubsub://
and Eventbridge ARNs are handled today.

Updates the validation error message to mention kafka and adds tests
for accepting a well-formed kafka URI, rejecting invalid topic
characters, and including kafka in the combined-URI subscriptions test
(which expands and sorts alphabetically by URI). Also disambiguates a
pre-existing duplicate http:// rejection test title in the same
describe block to keep the suite legible.

Resolves shop/issues-event-foundations#252.
@dpeacock dpeacock force-pushed the add-kafka-webhook-uri-validation branch from 039a03f to 9540872 Compare June 19, 2026 02:25
@dpeacock dpeacock enabled auto-merge June 22, 2026 13:59
@dpeacock dpeacock added this pull request to the merge queue Jun 22, 2026
Merged via the queue into main with commit 65f5775 Jun 22, 2026
28 checks passed
@dpeacock dpeacock deleted the add-kafka-webhook-uri-validation branch June 22, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: @shopify/cli @shopify/cli package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants