Skip to content

fix: restore os.Args after plugin completion and fix error return#6817

Open
luojiyin1987 wants to merge 1 commit intodocker:masterfrom
luojiyin1987:fix-plugin-cobra
Open

fix: restore os.Args after plugin completion and fix error return#6817
luojiyin1987 wants to merge 1 commit intodocker:masterfrom
luojiyin1987:fix-plugin-cobra

Conversation

@luojiyin1987
Copy link
Contributor

- What I did

Fix two issues in the plugin manager:

  1. Fix error return value: The plugin stub was returning the wrong error variable when flag parsing failed
  2. Restore os.Args after plugin completion: The global os.Args was being modified during plugin completion but not restored, which could cause side effects in subsequent code

- How I did it

  1. Changed the error return from err to perr when flag parsing fails
  2. Added code to save the original os.Args before modification and use defer to restore it
  3. Added comprehensive tests to verify both fixes

- Files changed:

File Change
cli-plugins/manager/cobra.go Fix error return + restore os.Args
cli-plugins/manager/cobra_test.go Add regression tests

- How to verify it

The new tests verify both scenarios.

- Description for the changelog

bug fix: restore os.Args after plugin completion and fix error return

Fixes #6816

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops! I started reviewing, but didn't submit 🙈

Signed-off-by: luojiyin <luojiyin@hotmail.com>
@luojiyin1987
Copy link
Contributor Author

Updated in commit 402b1db and addressed all review points (inline parse error handling, helper returns error, stdlib temp file setup, and config patch simplification). I also resolved the review threads.\n\n@thaJeztah could you please take another look when you have a moment? Thanks!

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: restore os.Args after plugin completion and fix error return

3 participants