ESD-1633-fix(wasm): stop SplitArgs deleting a literal megaport argument#520
Open
Phil-Browne wants to merge 2 commits into
Open
ESD-1633-fix(wasm): stop SplitArgs deleting a literal megaport argument#520Phil-Browne wants to merge 2 commits into
Phil-Browne wants to merge 2 commits into
Conversation
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.
Contributor
There was a problem hiding this comment.
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
SplitArgsto strip the program name only when it appears as the first token. - Add regression tests covering
megaportas 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 Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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 🚀 New features to boost your workflow:
|
penzeliz-megaport
approved these changes
Jul 13, 2026
penzeliz-megaport
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed for correctness; no findings. LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a WASM-only bug where
SplitArgsdropped any argument equal tomegaport,megaport-cli, or./megaport-cli, not just a leading program name. That meant a command likeports update <uid> --name megaportsilently lost the flag value.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.