Handle missing theme write access during theme creation#7941
Open
mbarak wants to merge 1 commit into
Open
Conversation
Route theme creation through the theme Admin request wrapper so ACCESS_DENIED responses use the existing friendly missing access error. Normalize requiredAccess prose that starts with "The user needs" before embedding it in the user-facing message. Co-authored-by: Pi AI <noreply@pi.dev> Assisted-By: devx/a1027ad2-ceec-4016-b728-d7c842f1fe88
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the UX for themeCreate failures when the authenticated identity lacks theme write access by routing the mutation through the existing theme Admin request wrapper that already converts ACCESS_DENIED + requiredAccess GraphQL errors into a friendly AbortError.
Changes:
- Route
themeCreatethroughrequestThemeAdminDocso missing theme access produces the established friendly error/next-steps instead of a raw GraphQLClientError. - Normalize
requiredAccessstrings (strip trailing period and leading “The user needs …”) so the rendered error reads cleanly. - Add a regression test covering the
themeCreateaccess-denied path, and include a changeset documenting the user-visible behavior change.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/cli-kit/src/public/node/themes/api.ts | Route themeCreate via the theme request wrapper and introduce requiredAccess formatting for cleaner abort messaging. |
| packages/cli-kit/src/public/node/themes/api.test.ts | Add a regression test for friendly access-denied messaging and extend the test helper to support non-themes fields. |
| .changeset/friendly-theme-create-access-error.md | Add a patch changeset describing the improved error behavior for denied theme creation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WHY are these changes introduced?
When theme commands create a development theme with an account or Admin API token that cannot access
themeCreate, the Admin GraphQL API returns anACCESS_DENIEDerror withrequiredAccessdetails.fetchThemesand related read paths already map this shape to a friendlyAbortError, butthemeCreatestill calledadminRequestDocdirectly and surfaced the raw GraphQLClientErrorpayload.This addresses the latest-version
write_themes/themeCreatetail under the linked issue; the broader Observe grouping also contains unrelated GraphQL failures that should be re-scoped separately.WHAT is this pull request doing?
themeCreatethrough the theme Admin request wrapper so missing theme access is reported with the existing friendly next steps.requiredAccesstext that starts withThe user needs ...so the rendered error sentence reads cleanly.themeCreateregression test.How to test your changes?
pnpm --filter @shopify/cli-kit vitest run src/public/node/themes/api.test.tspnpm --filter @shopify/cli-kit lintpnpm --filter @shopify/cli-kit type-checkResolves: https://github.com/shop/issues/issues/32995
Co-authored-by: Pi AI noreply@pi.dev