Skip to content

Filter requested extension templates before flag checks#7857

Merged
durga256 merged 1 commit into
mainfrom
fix-template-flag-filtering
Jun 18, 2026
Merged

Filter requested extension templates before flag checks#7857
durga256 merged 1 commit into
mainfrom
fix-template-flag-filtering

Conversation

@durga256

@durga256 durga256 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

shopify app generate extension --template=discount can fail when an unrelated extension template in the remote template list is gated by organization Beta/ExP flags.

The App Management template path downloads all extension templates and evaluates flags before the requested template is resolved. If any unrelated template has organizationExpFlags, the CLI can query Business Platform even though the requested template does not need those flags. In auth contexts that cannot call the BP Organizations flag endpoint, that unrelated flag check can fail the command.

WHAT is this pull request doing?

  • Threads the requested --template through extension-template fetching.
  • Filters App Management templates to the requested template before running Beta/ExP flag checks.
  • Keeps existing behavior for interactive generation, where all visible templates still need filtering.
  • Adds regression coverage to ensure unrelated gated templates do not trigger BP flag requests when a specific template is requested.
  • Adds a patch changeset for @shopify/app.

How to test your changes?

pnpm --filter @shopify/app exec eslint \
  src/cli/services/generate.ts \
  src/cli/services/generate.test.ts \
  src/cli/services/generate/fetch-template-specifications.ts \
  src/cli/services/generate/fetch-template-specifications.test.ts \
  src/cli/utilities/developer-platform-client.ts \
  src/cli/utilities/developer-platform-client/app-management-client.ts \
  src/cli/utilities/developer-platform-client/app-management-client.test.ts \
  src/cli/utilities/developer-platform-client/partners-client.ts

pnpm --filter @shopify/app vitest --run \
  src/cli/services/generate.test.ts \
  src/cli/utilities/developer-platform-client/app-management-client.test.ts \
  src/cli/services/generate/fetch-template-specifications.test.ts

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — I've identified the correct bump type and added a changeset

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions Bot added the Area: @shopify/app @shopify/app package issues label Jun 18, 2026
@durga256
durga256 marked this pull request as ready for review June 18, 2026 15:39
Copilot AI review requested due to automatic review settings June 18, 2026 15:39
@durga256
durga256 requested review from a team as code owners June 18, 2026 15:39

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 prevents shopify app generate extension --template=... from failing due to organization Beta/ExP flag checks on unrelated remote templates by threading the requested template through template-spec fetching and filtering App Management templates before flag evaluation.

Changes:

  • Extend DeveloperPlatformClient.templateSpecifications to accept an optional {requestedTemplate} and thread it from generatefetchExtensionTemplates.
  • In AppManagementClient, pre-filter templates to the requested identifier before running allowedTemplates (avoiding BP flag calls for unrelated templates).
  • Add regression tests ensuring unrelated gated templates do not trigger BP flag requests when a specific template is requested, plus a changeset for @shopify/app.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/app/src/cli/utilities/developer-platform-client/partners-client.ts Updates templateSpecifications signature to accept the new optional options parameter.
packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts Filters templates to the requested identifier before running org flag checks.
packages/app/src/cli/utilities/developer-platform-client/app-management-client.test.ts Adds regression coverage ensuring unrelated templates don’t trigger BP flag calls when requesting a specific template.
packages/app/src/cli/utilities/developer-platform-client.ts Introduces TemplateSpecificationsOptions and updates the DeveloperPlatformClient interface signature.
packages/app/src/cli/services/generate/fetch-template-specifications.ts Threads requested template to developerPlatformClient.templateSpecifications.
packages/app/src/cli/services/generate/fetch-template-specifications.test.ts Verifies requestedTemplate is passed through to the platform client.
packages/app/src/cli/services/generate.ts Passes {requestedTemplate: template} into fetchExtensionTemplates.
packages/app/src/cli/services/generate.test.ts Verifies generate passes the requested template when fetching extension templates.
.changeset/quiet-crabs-fix.md Patch changeset describing the user-facing fix.

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

Comment on lines +498 to +500
const templatesToFilter = options.requestedTemplate
? templates.filter((template) => template.identifier === options.requestedTemplate)
: templates

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.

I agree with copilot here, that looks to be the main risk with this change.

@durga256 durga256 Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is actually interesting as i could go two ways.
1. falls back to filtering the full template list with “allow all flags”(currently done). allow all flags: better diagnostic completeness, but may overstate availability.
2. deny all flags / ungated-only: safer semantics, but may under-list available gated templates.

Long term would be a new error based on “known identifiers” vs “available identifiers” but yeah

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.

IMO we could fall back to the current scenario of showing all templates when there's a mismatch. @isaacroldan I'm curious what you think?

@isaacroldan isaacroldan Jun 18, 2026

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.

I think that's the safest solution. The main reason for this PR is because automated runs can't run the organizations query to get the beta flags, so avoidiing that if possible is great.

If the template you specified doesn't exist, we should go back to the default behaviour: Don't show in the list templates you can't really create.

This is mostly a fix for us, normal usage of --template will be authenticated and manual (even if agentic), so it'd be ok to fetch the beta flags

Comment thread packages/app/src/cli/services/generate/fetch-template-specifications.ts Outdated
@durga256
durga256 force-pushed the fix-template-flag-filtering branch 2 times, most recently from 8fc277e to 2630997 Compare June 18, 2026 15:54
Assisted-By: devx/a755b2ec-b72c-4514-8a02-9c47c628c61b
@durga256
durga256 force-pushed the fix-template-flag-filtering branch from 2630997 to 0323612 Compare June 18, 2026 16:17
@durga256
durga256 added this pull request to the merge queue Jun 18, 2026
Merged via the queue into main with commit 5d932f0 Jun 18, 2026
28 checks passed
@durga256
durga256 deleted the fix-template-flag-filtering branch June 18, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: @shopify/app @shopify/app package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants