Conversation
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.5.0)level=warning msg="[linters_context] running gomodguard failed: unable to read module file go.mod: current working directory must have a go.mod file: if you are not using go modules it is suggested to disable this linter" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/cmd/cli/command/whoami.go (1)
34-44:⚠️ Potential issue | 🔴 CriticalAdd nil-guard to
ResolveWorkspaceNameor guard the call incli.Whoami.The
ResolveWorkspaceNamefunction atsrc/pkg/cli/workspace.go:40callsinfo.FindWorkspaceInfo(tenantSelection)without checking ifinfois nil. WhenuserInfoisnilin CI mode (global.HasTty false), the call toResolveWorkspaceName(userInfo, tenantSelection)atsrc/pkg/cli/whoami.go:42will panic.Either:
- Add a nil check at the start of
ResolveWorkspaceName:if info == nil { return "" }- Or guard the call in
Whoamibefore line 42: only callResolveWorkspaceNameifuserInfo != nil, otherwise setWorkspaceto an empty string or the tenant selection value🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/cmd/cli/command/whoami.go` around lines 34 - 44, Resolve the nil-deref by guarding ResolveWorkspaceName against a nil user info: update ResolveWorkspaceName(info, tenantSelection) to check if info == nil and return an empty string (or sensible default) before calling info.FindWorkspaceInfo(tenantSelection); alternatively, in cli.Whoami where Whoami(ctx, global.Client, provider, userInfo, global.Tenant) is invoked, only call ResolveWorkspaceName when userInfo != nil and set Workspace to "" or tenantSelection when userInfo is nil. Ensure you reference ResolveWorkspaceName, FindWorkspaceInfo, Whoami, and userInfo in the fix so the null path is handled and no panic occurs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/cmd/cli/command/whoami.go`:
- Around line 34-44: Resolve the nil-deref by guarding ResolveWorkspaceName
against a nil user info: update ResolveWorkspaceName(info, tenantSelection) to
check if info == nil and return an empty string (or sensible default) before
calling info.FindWorkspaceInfo(tenantSelection); alternatively, in cli.Whoami
where Whoami(ctx, global.Client, provider, userInfo, global.Tenant) is invoked,
only call ResolveWorkspaceName when userInfo != nil and set Workspace to "" or
tenantSelection when userInfo is nil. Ensure you reference ResolveWorkspaceName,
FindWorkspaceInfo, Whoami, and userInfo in the fix so the null path is handled
and no panic occurs.
Description
Skip the userinfo call on the CI by using
global.HasTty.Linked Issues
#1834
Checklist
Summary by CodeRabbit