Skip to content

Commit ae0a747

Browse files
RyanDJLeeclaude
andcommitted
Fix store auth scope parsing for space-separated input
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>
1 parent a21a899 commit ae0a747

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

packages/cli/src/cli/services/store/auth/scopes.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,30 @@ describe('store auth scope helpers', () => {
1717
expect(mergeRequestedAndStoredScopes(['read_products'], ['read_orders'])).toEqual(['read_orders', 'read_products'])
1818
})
1919

20+
test('parseStoreAuthScopes splits space-separated scopes', () => {
21+
expect(parseStoreAuthScopes('read_products read_inventory')).toEqual(['read_products', 'read_inventory'])
22+
})
23+
24+
test('parseStoreAuthScopes splits mixed comma-and-space delimiters', () => {
25+
expect(parseStoreAuthScopes('read_products, read_inventory,write_orders')).toEqual([
26+
'read_products',
27+
'read_inventory',
28+
'write_orders',
29+
])
30+
})
31+
32+
test('resolveGrantedScopes succeeds when requested scopes were space-separated', () => {
33+
expect(
34+
resolveGrantedScopes(
35+
{
36+
access_token: 'token',
37+
scope: 'read_products,read_inventory',
38+
},
39+
['read_products', 'read_inventory'],
40+
),
41+
).toEqual(['read_products', 'read_inventory'])
42+
})
43+
2044
test('resolveGrantedScopes accepts compressed write scopes that imply requested reads', () => {
2145
expect(
2246
resolveGrantedScopes(

packages/cli/src/cli/services/store/auth/scopes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {StoreTokenResponse} from './token-client.js'
44

55
export function parseStoreAuthScopes(input: string): string[] {
66
const scopes = input
7-
.split(',')
7+
.split(/[\s,]+/)
88
.map((scope) => scope.trim())
99
.filter(Boolean)
1010

0 commit comments

Comments
 (0)