You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes local OAuth workspace sessions that could render the credential workspace id as both the display name and id in auth workspace list and selection flows. The command now upgrades cached placeholder metadata when the Management API can resolve the workspace.
Changes
Adds best-effort hydration for local OAuth workspace metadata in packages/cli/src/controllers/auth.ts before list, use, and logout paths consume cached sessions.
Updates FileTokenStorage in packages/cli/src/adapters/token-storage.ts so unresolved placeholder metadata falls back to Unknown workspace instead of treating the credential id as a display name.
Preserves service-token precedence: PRISMA_SERVICE_TOKEN remains the active source while cached local OAuth sessions are still shown as non-switchable.
Expands auth regression coverage for hydrated list output, unresolved fallback behavior, interactive picker labels, and compact table formatting consistency.
Why
The presenter was faithfully rendering bad cached metadata, so masking only the table output would leave auth workspace use picker labels and name-based flows wrong. Hydrating at the storage/controller boundary repairs existing local state opportunistically while keeping the command usable when API lookup fails.
The PR adds OAuth workspace metadata hydration to the CLI's auth subsystem. In token-storage.ts, a new UNKNOWN_WORKSPACE_NAME constant and workspaceDisplayName helper replace direct use of the raw credential workspace ID as a display fallback, and a new listWorkspaceTokens() method reads stored credential tokens from disk. In auth.ts, a set of internal helpers (hydrateLocalAuthWorkspaces, resolveOAuthWorkspaceMetadata, createSingleWorkspaceTokenStorage, etc.) resolve workspace id/name by calling GET /v1/workspaces/{id} via the management API, persist resolved metadata back to storage, and are wired as a pre-step into listRealAuthWorkspaces, useRealAuthWorkspace, and logoutRealAuthWorkspace. Tests cover successful hydration, 404 fallback behavior, and the interactive workspace picker.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name
Status
Explanation
Resolution
Docstring Coverage
⚠️ Warning
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.
Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name
Status
Explanation
Title check
✅ Passed
The title accurately describes the main change: adding hydration of workspace list names to fix the display issue with local OAuth workspace sessions.
Linked Issues check
✅ Passed
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
✅ Passed
Check skipped because no linked issues were found for this pull request.
Description check
✅ Passed
The PR description clearly relates to the changeset, explaining a fix for local OAuth workspace sessions that render incorrect metadata, with details on what was changed and why.
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches🧪 Generate unit tests (beta)
Create PR with unit tests
Commit unit tests in branch fix/auth-workspace-list-names
✨ Simplify code
Create PR with simplified code
Commit simplified code in branch fix/auth-workspace-list-names
Comment @coderabbitai help to get the list of available commands and usage tips.
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
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.
Overview
Fixes local OAuth workspace sessions that could render the credential workspace id as both the display name and id in
auth workspace listand selection flows. The command now upgrades cached placeholder metadata when the Management API can resolve the workspace.Changes
packages/cli/src/controllers/auth.tsbefore list, use, and logout paths consume cached sessions.FileTokenStorageinpackages/cli/src/adapters/token-storage.tsso unresolved placeholder metadata falls back toUnknown workspaceinstead of treating the credential id as a display name.PRISMA_SERVICE_TOKENremains the active source while cached local OAuth sessions are still shown as non-switchable.Why
The presenter was faithfully rendering bad cached metadata, so masking only the table output would leave
auth workspace usepicker labels and name-based flows wrong. Hydrating at the storage/controller boundary repairs existing local state opportunistically while keeping the command usable when API lookup fails.