fix(parse)!: Remove csv-style parsing for lists and maps - #395
Conversation
2e442b8 to
89f1bc0
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates instance-related commands to correctly accept environment variables in KEY=VALUE form even when values contain commas, by preventing Kong’s default comma-splitting and handling parsing explicitly before shortcut-flag processing.
Changes:
- Set
sep:"none"for-e/--envon instance create/edit to avoid Kong splitting values on commas. - Pre-process
Envinto--set runtime.env=...entries before applying generic shortcut flags (create/edit/run). - Add helpers to split and encode env assignments as JSON map fragments for consistent patch parsing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/cmd/run.go | Pre-processes --env into --set entries before generic shortcut handling to support KEY=VALUE parsing. |
| internal/cmd/instances.go | Disables Kong comma-splitting for --env, adds env parsing helpers, and applies the same pre-processing for create/edit. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
craciunoiuc
left a comment
There was a problem hiding this comment.
Some comments my side 🥺
89f1bc0 to
5311264
Compare
5311264 to
a8d856f
Compare
|
@nurof3n tests failing 😳 Also please close copilot comments which no longer apply Looks much leaner now 🫦 |
a8d856f to
937a9a1
Compare
e3747f8 to
e6c6fd6
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 21 changed files in this pull request and generated no new comments.
Suppressed comments (3)
internal/cmd/instances.go:265
- This drops the previous
strings.TrimSpacenormalization fromInstanceService.UnmarshalText.multimetro.ParseKeydoes not trim its input, so a value such as--service " my-service "now produces a link whose name contains spaces and fails lookup. Preserve the existing normalization before parsing the link.
link, err := ParseLink[ServiceGroup](data)
internal/resource/patch/visual.go:229
- Please add a regression test for the new deepest-first behavior. The current visual-edit tests cover nested child fields, but not a settable ancestor sharing the same YAML subtree with a settable descendant—the exact case this ordering fixes. A service-like fixture should verify that the ancestor's own link/name and a descendant collection both survive deserialization, and that unknown nested fields are still rejected.
slices.SortStableFunc(entries, func(a, b fieldEntry) int {
return cmp.Compare(len(b.key), len(a.key))
})
internal/cmd/volumes.go:110
- Integration coverage is incomplete for the newly renamed
volume clone --tagshortcut; the existing volume integration only exercises--tagduring create, while clone has its own manual patch-to-request path. Please create a source volume, clone it with repeated--tagflags, inspect that the clone has distinct tags (including the literal-comma behavior), and clean up both volumes.
Tag []string `group:"flag-clone" shortcut:"tags" sep:"none" help:"Volume tag." placeholder:"tag" example:"env-prod"`
e6c6fd6 to
4ceefde
Compare
craciunoiuc
left a comment
There was a problem hiding this comment.
All good here. Thanks!
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.com>
Approved-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.com>
|
that's a lot of edge cases, now I'm scared there are more 👀 |
|
The last commit is a pre-existing issue, I can split to a separate PR tbf. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.
Suppressed comments (9)
internal/cmd/volumes.go:110
- The new
volume clone --taginterface has no integration coverage; the clone test still uses only--set name. Please clone with repeated--tag, inspect the clone to confirm separate tag values and success, cover rejection of the removed--tagsspelling, and delete both clone and source.
Tag []string `group:"flag-clone" shortcut:"tags" sep:"none" help:"Volume tag." placeholder:"tag" example:"env-prod"`
internal/resource/value/parse.go:155
- This comment contradicts the implementation and the new
map key with no valuetest:field=has a non-empty key and addsfield: "". The skipped form is an entry such as=value. Please describe that case so future callers do not rely on incorrect parsing semantics.
// not from splitting one input. Only the key is trimmed, and an
// empty key is skipped so a bare "field=" adds no entry.
internal/cmd/services.go:79
- Integration coverage is incomplete for the renamed service edit shortcuts: current integration tests exercise repeated
--domain/--serviceonly during creation, while edit still uses--set. Please add an end-to-end edit using repeated singular flags, inspect the resulting domains/ports and exit status, verify the removed plural flags are rejected, and clean up the service group.
Domain []Domain `group:"flag-edit" shortcut:"domains" sep:"none" help:"Service domain." placeholder:"fqdn" example:"example.com"`
Service []Service `group:"flag-edit" shortcut:"services" sep:"none" help:"Service port." placeholder:"<src>:<dest>[/<handlers>]" example:"443:8080/http+tls"`
internal/cmd/volumes.go:94
- Integration coverage is missing for the renamed volume edit shortcut. Please edit a live volume with repeated
--tag, verify inspect/list observes separate tags and a successful exit, check that the removed--tagsform is rejected, and clean up the volume.
This issue also appears on line 110 of the same file.
Tag []string `group:"flag-edit" shortcut:"tags" sep:"none" help:"Volume tag." placeholder:"tag" example:"env-prod"`
internal/cmd/instances.go:152
- Integration coverage is missing for the renamed instance edit
--tagshortcut; existing tag scenarios use it only on create and use--setfor edits. Please edit a live instance with repeated--tag, verify the resulting separate tags and exit status, assert that legacy--tagsis rejected, and delete the instance.
Tag []string `group:"flag-edit" shortcut:"tags" sep:"none" help:"Instance tag." placeholder:"tag" example:"env-prod"`
internal/cmd/instance_templates.go:64
- The user-facing template edit flag is renamed to
--tag, but the integration test still edits tags exclusively through repeated--set. Please exercise repeated--tagend to end, inspect/filter for both separate values, verify--tagsis rejected, and retain the existing template/resource cleanup.
Tag []string `group:"flag-edit" shortcut:"tags" sep:"none" help:"Template tag." placeholder:"tag" example:"env-dev"`
internal/cmd/volume_templates.go:64
- The renamed volume-template
--tagshortcut lacks integration coverage because the current test uses--set tags=.... Please edit a template with repeated--tag, inspect/filter to prove the values remain separate, cover rejection of--tags, and preserve cleanup of the template and source volume.
Tag []string `group:"flag-edit" shortcut:"tags" sep:"none" help:"Template tag." placeholder:"tag" example:"env-dev"`
internal/cmd/instance_checkpoints.go:67
- The checkpoint edit flag now exposes
--tag, but integration coverage still goes through repeated--set. Please edit a checkpoint with repeated--tag, inspect/filter for both separate tags and a successful exit, verify the removed--tagsspelling fails, and clean up the checkpoint and instance.
Tag []string `group:"flag-edit" shortcut:"tags" sep:"none" help:"Checkpoint tag." placeholder:"tag" example:"env-dev"`
internal/resource/patch/visual.go:229
- The nested visual-editing behavior is covered only by a unit test, but it changes the end-to-end CLI path. Please add an integration case that creates an instance with
--service, repeated nested--domain/--publish, and a noninteractive editor such as--cmd cat; then inspect the service link, domains, and ports, assert the exit status, and clean up the instance/service resources.
slices.SortStableFunc(entries, func(a, b fieldEntry) int {
return cmp.Compare(len(b.key), len(a.key))
})
| data, err := yaml.Marshal(v) | ||
| if err != nil { | ||
| return map[string]any{} |
|
nah, no need but do check if there are any cases left I will also do a pass soon, might start a robot in parallel to look for any edge cases |
70f937d to
f607120
Compare
|
static check failed, in case you are wondering why, it's because golangci-lint got updated and the new version has more checks in X it's better to pin down, but here maybe we can live with the bump? that being said, should the fix be here or in a separate PR? |
|
Let's fix it separately, yes. I'll pin it down in x. |
craciunoiuc
left a comment
There was a problem hiding this comment.
All good here. Thanks!
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.com>
Approved-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.com>
Signed-off-by: Alex-Andrei Cioc <andrei.cioc@unikraft.io>
Signed-off-by: Alex-Andrei Cioc <andrei.cioc@unikraft.io>
And rename flags to make this clearer. So `--tags` becomes `--tag`, etc. This is a major breaking change, however, the end result should be significantly clearer. In the future, we should work out how to remove the CSV values for struct parsing as well, however, this is much trickier, especially as we are dependent on this in more places. Signed-off-by: Justin Chadwell <justin@unikraft.com>
Signed-off-by: Justin Chadwell <justin@unikraft.com>
Signed-off-by: Justin Chadwell <justin@unikraft.com>
f607120 to
c82c772
Compare
craciunoiuc
left a comment
There was a problem hiding this comment.
All good here. Thanks!
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.com>
Approved-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.com>

Closes TOOL-1125