Skip to content

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

@luojiyin1987

Description

@luojiyin1987

Description

This PR fixes 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

Files changed:

  • cli-plugins/manager/cobra.go:

    • Line 50: Return perr instead of err
    • Lines 63-66: Save and restore original os.Args using defer
  • cli-plugins/manager/cobra_test.go:

    • Add tests for the above fixes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions