Verified Solution

[docker/cli] fix: restore os.Args after plugin completion and fix error return

Sponsored Content
### ROOT CAUSE The issue stems from two problems in the plugin manager: 1. **Incorrect Error Handling**: The plugin stub was returning the wrong error variable (`err` instead of `perr`) when flag parsing failed, leading to incorrect error handling by callers. 2. **Unrestored `os.Args`**: The global `os.Args` was being modified during plugin execution but not restored, causing potential side effects in subsequent code that relies on the original command line arguments. ### CODE FIX The fix involves two changes in `cli-plugins/manager/cobra.go`: 1. **Fix Error Return**: Replace the return statement at line 50 to return `perr` (the correct error variable) instead of `err`. 2. **Restore `os.Args`**: Use a `defer` statement to save and restore the original `os.Args` before and after plugin execution. Here are the exact changes: ```go // Line 50: Change the error return return perr ``` ```go // Lines 63-66: Add code to save and restore os.Args originalArgs := make([]string, len(os.Args)) copy(originalArgs, os.Args) defer func() { os.Args = originalArgs }() ``` Additionally, update the tests in `cli-plugins/manager/cobra_test.go` to verify the fixes.
Deploy on DigitalOcean ($200 Credit)

Related Fixes

[golang/go] proposal: x/net/html: add a ParseOption to control open element stack limit
[microsoft/vscode] Ollama models are not detected in Chat
[golang/go] proposal: reflect: `add Value.TypeAssert[T any]`