Skip to content

ESD-1633-fix(wasm): stop SplitArgs deleting a literal megaport argument#520

Open
Phil-Browne wants to merge 2 commits into
mainfrom
worktree-esd-1633-wasm-splitargs-megaport-token
Open

ESD-1633-fix(wasm): stop SplitArgs deleting a literal megaport argument#520
Phil-Browne wants to merge 2 commits into
mainfrom
worktree-esd-1633-wasm-splitargs-megaport-token

Conversation

@Phil-Browne

Copy link
Copy Markdown
Contributor

Fixes a WASM-only bug where SplitArgs dropped any argument equal to megaport, megaport-cli, or ./megaport-cli, not just a leading program name. That meant a command like ports update <uid> --name megaport silently lost the flag value.

  • Only strip a program-name token when it's the first token, leaving later flag values and positionals intact.
  • Added test cases covering a megaport-valued flag, a positional, and a leading token combined with a later literal value.

Ran go build, go test ./..., the WASM build, WASM package tests, and lint locally; all pass.

SplitArgs filtered the leading program-name token against every argument
instead of just the first, so any flag value or positional equal to
"megaport", "megaport-cli", or "./megaport-cli" was silently dropped
(e.g. ports update <uid> --name megaport). Only strip a matching token
at position 0.
Combines both fixed cases in one input, matching the ticket's original
repro shape most closely.
Copilot AI review requested due to automatic review settings July 10, 2026 15:54
@Phil-Browne Phil-Browne requested review from a team and penzeliz-megaport as code owners July 10, 2026 15:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a WASM-only argument parsing bug in internal/wasm.SplitArgs where literal values equal to megaport, megaport-cli, or ./megaport-cli were incorrectly dropped even when they appeared as flag values or positional arguments. This aligns SplitArgs with how the WASM entrypoint (main_wasm.go) constructs the final argv (it prepends the program name itself).

Changes:

  • Update SplitArgs to strip the program name only when it appears as the first token.
  • Add regression tests covering megaport as a flag value and positional, plus the “leading program name + later literal value” case.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/wasm/wasm.go Restricts program-name stripping to the first token to prevent dropping legitimate argument values.
internal/wasm/wasm_test.go Adds targeted test cases to prevent regressions for literal megaport values in non-leading positions.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.58%. Comparing base (9ba6a3b) to head (e2e9c47).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #520      +/-   ##
==========================================
+ Coverage   78.57%   78.58%   +0.01%     
==========================================
  Files         192      192              
  Lines       18522    18522              
==========================================
+ Hits        14553    14555       +2     
+ Misses       2904     2902       -2     
  Partials     1065     1065              

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@penzeliz-megaport penzeliz-megaport left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed for correctness; no findings. LGTM.

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.

3 participants