Fix --alias to also match by userId for UUID-aliased sessions#6933
Conversation
|
Not sure how to rerun the CLA check, but I signed it at cla.shopify.com |
|
🤖 Code Review · #projects-dev-ai for questions ✅ Complete - No issues 📋 History✅ No issues |
gonzaloriestra
left a comment
There was a problem hiding this comment.
Thanks a lot for the PR! It makes sense to me. The failing checks don't work correctly on forks, so I will merge anyway and ensure they pass on main later.
Related to this, in #6935 I'm asking for the alias on login when it can't be fetched. Would that be helpful for you? Could you please give it a try? npm i -g @shopify/cli@0.0.0-snapshot-20260304105215
|
Appreciate the merge! Thanks for getting it in quickly. Regarding #6935 — I installed the snapshot and tried That said, I might be misunderstanding the change — does it cover that scenario too? Here's my terminal output if that helps you with anything: |
|
Thanks for the feedback, very useful! I prepared another snapshot: |
WHY are these changes introduced?
When a session's email alias fails to resolve during login, the
aliasfield ends up asundefined. The session list display falls back to showinguserId(UUID) viasession.identity.alias ?? userId. ButfindSessionByAliasonly matches againstsession.identity.alias, so--alias <UUID>doesn't find anything and falls through to the interactive prompt.(The personal context is that I have a few different staff/partner accounts I work through so in every separate theme folder on my machine I automatically run
shopify auth login --aliaswith the appropriate account - around 15 times a day).WHAT is this pull request doing?
findSessionByAliasnow also matches on the session'suserIdkey as a fallback, so--alias <UUID>works for sessions where the alias was never set.One-line change in
store.ts, one new test instore.test.ts.Note: this does not fix the display issue — sessions with undefined aliases will still show as UUIDs in the session picker. That would require re-fetching the email at some point (e.g. during token refresh).
How to test your changes?
pnpm -F @shopify/cli-kit test -- src/private/node/session/store.test.tsshopify auth login --alias "<UUID>"falls through to the interactive prompt instead of selecting the session. On the patched build, it selects the session correctly.Measuring impact
Checklist