refactor(client|workspace): remove unused client options#605
refactor(client|workspace): remove unused client options#605skevetter merged 2 commits intoskevetter:mainfrom
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughClient API signatures changed: Create and Start lost their options parameters; Status and ParseStatus now return plain strings. All client implementations, workspace/machine usage, and CLI callers were updated to the new signatures and string-based status handling. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
c32b3de to
748f292
Compare
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)
pkg/client/clientimplementation/workspace_client.go (1)
559-588:⚠️ Potential issue | 🟠 MajorValidate machine provider status before returning or using it.
The
machineClient.Status()path returns the raw provider output without normalizing it throughParseStatus(), whilegetContainerStatus()correctly validates its output. This creates an inconsistency:StartWait()has adefaultcase (line 896) that treats any unrecognized status value as success, so a typo or backend-specific string in the machine provider's status could incorrectly mark the workspace as ready.Parse the machine status before the comparison and return:
status, err := machineClient.Status(ctx, options) if err != nil { return client.StatusNotFound, err } + status, err = client.ParseStatus(status) + if err != nil { + return client.StatusNotFound, err + } // try to check container status and if that fails check workspace folder if status == client.StatusRunning && options.ContainerStatus { return s.getContainerStatus(ctx) } return status, nil🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/client/clientimplementation/workspace_client.go` around lines 559 - 588, The machine provider path returns raw status from machineClient.Status() without normalizing it via ParseStatus(), risking unrecognized strings being treated as success; after calling machineClient.Status(ctx, options) pass the returned status through ParseStatus() (e.g. ParseStatus(status)) and use the parsed value for comparisons and returns: if parsed == client.StatusRunning and options.ContainerStatus then call s.getContainerStatus(ctx), otherwise return the parsed status (and propagate any ParseStatus error if it returns one) instead of the raw provider string so StartWait's default handling can't misinterpret provider-specific/typoed values.
🤖 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 `@pkg/client/clientimplementation/workspace_client.go`:
- Around line 559-588: The machine provider path returns raw status from
machineClient.Status() without normalizing it via ParseStatus(), risking
unrecognized strings being treated as success; after calling
machineClient.Status(ctx, options) pass the returned status through
ParseStatus() (e.g. ParseStatus(status)) and use the parsed value for
comparisons and returns: if parsed == client.StatusRunning and
options.ContainerStatus then call s.getContainerStatus(ctx), otherwise return
the parsed status (and propagate any ParseStatus error if it returns one)
instead of the raw provider string so StartWait's default handling can't
misinterpret provider-specific/typoed values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c0db4e51-c074-45f3-a1fb-0bbc66abe455
📒 Files selected for processing (9)
cmd/machine/create.gocmd/machine/start.gocmd/troubleshoot.gopkg/client/client.gopkg/client/clientimplementation/daemonclient/status.gopkg/client/clientimplementation/machine_client.gopkg/client/clientimplementation/proxy_client.gopkg/client/clientimplementation/workspace_client.gopkg/workspace/workspace.go
748f292 to
a6dda58
Compare
a6dda58 to
61d55fe
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/client/clientimplementation/daemonclient/status.go (1)
35-35: Normalize the daemon status before returning it.
StartWaitinpkg/client/clientimplementation/workspace_client.goLines 897-918 treats any non-canonical status as ready. Returninginstance.Status.LastWorkspaceStatusraw here skipsclientpkg.ParseStatus, so a casing or spelling drift from the platform would bypass the stopped/busy/not-found branches.Suggested change
- return string(instance.Status.LastWorkspaceStatus), nil + parsedStatus, err := clientpkg.ParseStatus(string(instance.Status.LastWorkspaceStatus)) + if err != nil { + return clientpkg.StatusNotFound, fmt.Errorf("parse platform status: %w", err) + } + + return parsedStatus, nil🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/client/clientimplementation/daemonclient/status.go` at line 35, The function returning instance.Status.LastWorkspaceStatus should normalize the status using clientpkg.ParseStatus before returning so non-canonical casing/spelling doesn't bypass StartWait's checks; update the return in status.go to call clientpkg.ParseStatus (or the appropriate ParseStatus function used by StartWait), handle any parse error (returning a safe default or the error) and then return the canonical string from the parsed status instead of the raw instance.Status.LastWorkspaceStatus.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pkg/client/clientimplementation/daemonclient/status.go`:
- Line 35: The function returning instance.Status.LastWorkspaceStatus should
normalize the status using clientpkg.ParseStatus before returning so
non-canonical casing/spelling doesn't bypass StartWait's checks; update the
return in status.go to call clientpkg.ParseStatus (or the appropriate
ParseStatus function used by StartWait), handle any parse error (returning a
safe default or the error) and then return the canonical string from the parsed
status instead of the raw instance.Status.LastWorkspaceStatus.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 27a3255a-1a3e-4329-bd53-fbed58cd5c58
📒 Files selected for processing (9)
cmd/machine/create.gocmd/machine/start.gocmd/troubleshoot.gopkg/client/client.gopkg/client/clientimplementation/daemonclient/status.gopkg/client/clientimplementation/machine_client.gopkg/client/clientimplementation/proxy_client.gopkg/client/clientimplementation/workspace_client.gopkg/workspace/workspace.go
🚧 Files skipped from review as they are similar to previous changes (3)
- cmd/troubleshoot.go
- pkg/workspace/workspace.go
- cmd/machine/create.go
|
@skevetter some tests seem to be stuck... |
974298a to
021e6f2
Compare
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)
pkg/client/client.go (1)
184-200:⚠️ Potential issue | 🟠 MajorReturn the unrecognized status value rather than
StatusNotFoundon parse failure.The current implementation converts any unrecognized status to
StatusNotFoundwith an error. This masks new backend states, making them indistinguishable from genuinely missing resources. When callers receive a parse error (in workspace_client.go and machine_client.go), they returnStatusNotFoundanyway, silencing the actual status value. Return the raw trimmed input in the default case to preserve information and allow proper diagnosis of unexpected statuses.Suggested fix
func ParseStatus(in string) (string, error) { - in = strings.ToUpper(strings.TrimSpace(in)) - switch in { + raw := strings.TrimSpace(in) + switch strings.ToUpper(raw) { case "RUNNING": return StatusRunning, nil case "BUSY": return StatusBusy, nil case "STOPPED": return StatusStopped, nil case "NOTFOUND": return StatusNotFound, nil default: - return StatusNotFound, fmt.Errorf( + return raw, fmt.Errorf( "error parsing status: '%s' unrecognized status, needs to be one of: %s", - in, + raw, []string{StatusRunning, StatusBusy, StatusStopped, StatusNotFound}, ) } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/client/client.go` around lines 184 - 200, The ParseStatus function currently returns StatusNotFound on unrecognized inputs which hides unknown backend states; update the default case in ParseStatus to return the raw trimmed input value (the local variable "in") along with the error instead of StatusNotFound so callers (e.g., workspace_client.go and machine_client.go) can see the actual unrecognized status; keep the existing error message but replace the returned status constant with the "in" variable.
🧹 Nitpick comments (1)
pkg/client/client.go (1)
25-27: Please call out these interface changes in the release notes.
pkg/clientis exported, and changingStatus,Create, andStarthere is a compile-time break for downstream implementations and callers. If this surface is supported outside this repo, add a short migration note.Also applies to: 47-54
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/client/client.go` around lines 25 - 27, The change made to the exported pkg/client interface (notably the signatures for Status(ctx context.Context, options StatusOptions), Create and Start) is a compile-time breaking change for downstream implementers; update the release notes to explicitly call out these interface changes, document the exact signature diffs (old vs new), provide a short migration note showing how to adapt implementations/callers to the new signatures, and ensure the same note covers the other altered methods referenced around the same area (lines with the other changed Signatures referenced in the diff, e.g., the block at 47-54) so downstream projects can upgrade smoothly.
🤖 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 `@pkg/client/client.go`:
- Around line 184-200: The ParseStatus function currently returns StatusNotFound
on unrecognized inputs which hides unknown backend states; update the default
case in ParseStatus to return the raw trimmed input value (the local variable
"in") along with the error instead of StatusNotFound so callers (e.g.,
workspace_client.go and machine_client.go) can see the actual unrecognized
status; keep the existing error message but replace the returned status constant
with the "in" variable.
---
Nitpick comments:
In `@pkg/client/client.go`:
- Around line 25-27: The change made to the exported pkg/client interface
(notably the signatures for Status(ctx context.Context, options StatusOptions),
Create and Start) is a compile-time breaking change for downstream implementers;
update the release notes to explicitly call out these interface changes,
document the exact signature diffs (old vs new), provide a short migration note
showing how to adapt implementations/callers to the new signatures, and ensure
the same note covers the other altered methods referenced around the same area
(lines with the other changed Signatures referenced in the diff, e.g., the block
at 47-54) so downstream projects can upgrade smoothly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f85d2f52-59b8-4827-9120-4330371a1afc
📒 Files selected for processing (9)
cmd/machine/create.gocmd/machine/start.gocmd/troubleshoot.gopkg/client/client.gopkg/client/clientimplementation/daemonclient/status.gopkg/client/clientimplementation/machine_client.gopkg/client/clientimplementation/proxy_client.gopkg/client/clientimplementation/workspace_client.gopkg/workspace/workspace.go
🚧 Files skipped from review as they are similar to previous changes (2)
- cmd/machine/start.go
- pkg/workspace/workspace.go
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 (2)
pkg/client/clientimplementation/workspace_client.go (2)
603-609:⚠️ Potential issue | 🟠 MajorDon't treat every
os.Statfailure asStatusNotFound.Line 604 currently maps permission and I/O errors to
NotFound. InStartWait, that can send callers down the create path even though the workspace folder still exists, which turns a transient filesystem problem into the wrong lifecycle action.Suggested fix
- _, err = os.Stat(workspaceFolder) - if err == nil { - return client.StatusRunning, nil - } - - return client.StatusNotFound, nil + if _, err := os.Stat(workspaceFolder); err == nil { + return client.StatusRunning, nil + } else if os.IsNotExist(err) { + return client.StatusNotFound, nil + } else { + return "", fmt.Errorf("stat workspace folder: %w", err) + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/client/clientimplementation/workspace_client.go` around lines 603 - 609, The current os.Stat(workspaceFolder) treats all errors as StatusNotFound; change the logic in the function that checks workspaceFolder (used by StartWait) to only return client.StatusNotFound when os.IsNotExist(err) is true, return client.StatusRunning when err == nil, and for any other error propagate the underlying error (do not map permission or I/O errors to NotFound) so callers like StartWait can handle transient filesystem errors correctly.
710-714:⚠️ Potential issue | 🟡 MinorFix the mislabeled container-status debug fields.
Line 711 logs the merged buffer as
stdout, and Line 712 logs the stdout buffer asstderr. When this path misbehaves, the debug record points at the wrong stream.Suggested fix
s.log.WithFields(logrus.Fields{ - "stdout": buf.String(), - "stderr": stdout.String(), - "parsed": parsed, + "stdout": stdout.String(), + "combinedOutput": buf.String(), + "parsed": parsed, }).Debug("container status command output")🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/client/clientimplementation/workspace_client.go` around lines 710 - 714, The debug log in s.log.WithFields is labeling the wrong buffers: it currently sets "stdout" to buf.String() and "stderr" to stdout.String(); swap these so "stdout" maps to stdout.String() and "stderr" maps to buf.String() (retain "parsed" and the Debug message). Update the call in the containing function/method where s.log.WithFields is used (referencing variables buf, stdout, parsed and the s.log.WithFields invocation) to correct the labels.
🤖 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 `@pkg/client/clientimplementation/workspace_client.go`:
- Around line 603-609: The current os.Stat(workspaceFolder) treats all errors as
StatusNotFound; change the logic in the function that checks workspaceFolder
(used by StartWait) to only return client.StatusNotFound when os.IsNotExist(err)
is true, return client.StatusRunning when err == nil, and for any other error
propagate the underlying error (do not map permission or I/O errors to NotFound)
so callers like StartWait can handle transient filesystem errors correctly.
- Around line 710-714: The debug log in s.log.WithFields is labeling the wrong
buffers: it currently sets "stdout" to buf.String() and "stderr" to
stdout.String(); swap these so "stdout" maps to stdout.String() and "stderr"
maps to buf.String() (retain "parsed" and the Debug message). Update the call in
the containing function/method where s.log.WithFields is used (referencing
variables buf, stdout, parsed and the s.log.WithFields invocation) to correct
the labels.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 66d5c06d-38c3-4e07-8ef8-d6d45a8c3476
📒 Files selected for processing (9)
cmd/machine/create.gocmd/machine/start.gocmd/troubleshoot.gopkg/client/client.gopkg/client/clientimplementation/daemonclient/status.gopkg/client/clientimplementation/machine_client.gopkg/client/clientimplementation/proxy_client.gopkg/client/clientimplementation/workspace_client.gopkg/workspace/workspace.go
🚧 Files skipped from review as they are similar to previous changes (3)
- pkg/client/clientimplementation/daemonclient/status.go
- cmd/troubleshoot.go
- cmd/machine/start.go
The test names were changed for #593. I will update them in a bit. |
|
@skevetter although |
Yes. I need to update the repository branch settings for the new test names. After I update it, it will remove the old test names from the list. |
f28bf00 to
ae99cf4
Compare
Thank you! |
cee9acf to
f547c3e
Compare
Signed-off-by: Leonid Dubinsky <dub@podval.org>
Signed-off-by: Leonid Dubinsky <dub@podval.org>
f547c3e to
759f13d
Compare
Summary by CodeRabbit
Refactor
New Features
Behavioral