Fix store auth scope parsing for space-separated input#7258
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the CLI’s store auth scope parsing to handle Windows PowerShell’s space-separated argument transformation, preventing false “granted fewer scopes” failures after OAuth.
Changes:
- Update
parseStoreAuthScopesto split scopes on both whitespace and commas. - Add unit tests for space-separated and mixed-delimiter scope inputs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/cli/src/cli/services/store/auth/scopes.ts | Broadens scope parsing to accept space- and comma-delimited input. |
| packages/cli/src/cli/services/store/auth/scopes.test.ts | Adds coverage for new parsing behavior and related grant-resolution scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
One thing I’d still like covered before merge: this was a shell/input-boundary bug, but the new tests stay at the The original failure path was broader: Could we either:
I think either would give us a much stronger cross-OS confidence story than helper tests alone. |
b08580c to
f4c0785
Compare
ebafe03 to
569d32a
Compare
569d32a to
a24ed11
Compare
a24ed11 to
a373448
Compare
Differences in type declarationsWe detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:
New type declarationsWe found no new type declarations in this PR Existing type declarationspackages/cli-kit/dist/public/node/node-package-manager.d.ts@@ -68,6 +68,10 @@ export declare function packageManagerFromUserAgent(env?: NodeJS.ProcessEnv): Pa
* @returns The dependency manager
*/
export declare function getPackageManager(fromDirectory: string): Promise<PackageManager>;
+export declare function packageManagerBinaryCommandForDirectory(directory: string, binary: string, ...args: string[]): Promise<{
+ command: string;
+ args: string[];
+}>;
interface InstallNPMDependenciesRecursivelyOptions {
/**
* The dependency manager to use to install the dependencies.
|
ac02da2 to
a21a899
Compare
b72644f to
ac02da2
Compare
parseStoreAuthScopes splits on commas only, but Windows PowerShell can transform comma-separated CLI args into space-separated strings before they reach Node.js. This causes "read_products read_inventory" to be treated as one unrecognized scope, triggering a false "fewer scopes than requested" error. Split on /[\s,]+/ instead — matching Core's own ScopeSet.parse_scopes which already handles both delimiters. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Narrow regex from /[\s,]+/ to /[ ,]+/ to match server-side Access::ScopeSet.parse_scopes behavior (space and comma only) - Remove dead .trim() — splitting on /[ ,]+/ can't produce elements with leading/trailing whitespace - Fix test that claimed to cover space-separated parsing but actually passed comma-separated input (exercising no new code) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collapse split/filter chain to single line to satisfy prettier. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Exercises the full authenticateStoreWithApp flow with space-separated
input ('read_products read_inventory') and comma-separated server
response, asserting the scopes resolve correctly and persist to the
session store. Addresses review feedback from dmerand.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…update Upstream schema updated JSDoc comments for Operator, ShopFilterField, and ShopFilterInput types (added IN operator documentation). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
a373448 to
ad4b9fa
Compare
|
/snapit |
|
🫰✨ Thanks @dmerand! Your snapshot has been published to npm. Test the snapshot by installing your package globally: npm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260413182601Caution After installing, validate the version by running |

Summary
Fixes
shopify store authfailing with "Shopify granted fewer scopes than were requested" when scope input arrives space-separated instead of comma-separated.parseStoreAuthScopessplit on commas only, but space-separated input (e.g."read_products read_inventory") was treated as a single unrecognized scopeAccess::ScopeSet.parse_scopes) handles both delimiters via/[ ,]/— the CLI parser now matches that behaviorRoot cause
A partner's CLI invocation delivered space-separated scopes to
parseStoreAuthScopes. The exact shell-level cause is unknown — possibly typed without commas, or a script/wrapper issue. The CLI's.split(',')produced["read_products read_inventory"](one element). The server parsed both formats correctly and returnedscope: "read_products,read_inventory". The CLI then failed validation because the single requested scope"read_products read_inventory"wasn't in the granted set{"read_products", "read_inventory"}.Confirmed via partner verbose logs showing
with scopes read_products read_inventory(no comma inscopes.join(',')output, proving a single-element array).Slack thread: https://shopify.slack.com/archives/C07UJ7UNMTK/p1776085829940879
Changes
scopes.ts:.split(',')→.split(/[ ,]+/)to handle both comma and space delimiters, matching the server-side regex.trim()— splitting on/[ ,]+/cannot produce elements with leading/trailing whitespacescopes.test.ts: new tests covering space-separated input, mixed delimiters, and space-separated granted scopes throughresolveGrantedScopesTest plan
parseStoreAuthScopes splits space-separated scopesfails before fix, passes aftershopify store auth --scopes read_products,read_inventoryon Windows PowerShell