Skip to content

fix(parse)!: Remove csv-style parsing for lists and maps - #395

Merged
jedevc merged 5 commits into
prod-stagingfrom
nurof3n/fix/instances-env-sep
Aug 20, 2026
Merged

fix(parse)!: Remove csv-style parsing for lists and maps#395
jedevc merged 5 commits into
prod-stagingfrom
nurof3n/fix/instances-env-sep

Conversation

@nurof3n

@nurof3n nurof3n commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Closes TOOL-1125

@nurof3n
nurof3n requested a review from jedevc July 3, 2026 12:54
@nurof3n
nurof3n force-pushed the nurof3n/fix/instances-env-sep branch from 2e442b8 to 89f1bc0 Compare July 6, 2026 13:05
@craciunoiuc
craciunoiuc requested a review from Copilot July 6, 2026 18:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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/--env on instance create/edit to avoid Kong splitting values on commas.
  • Pre-process Env into --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.

Comment thread internal/cmd/instances.go Outdated

@craciunoiuc craciunoiuc 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.

Some comments my side 🥺

Comment thread internal/cmd/instances.go
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread internal/cmd/instances.go Outdated
Comment thread internal/resource/value/parse_test.go Outdated
Comment thread internal/resource/value/parse.go Outdated
@nurof3n
nurof3n force-pushed the nurof3n/fix/instances-env-sep branch from 5311264 to a8d856f Compare July 7, 2026 13:00
@nurof3n
nurof3n requested a review from Copilot July 7, 2026 13:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread internal/resource/value/parse.go
Comment thread internal/resource/value/parse_test.go Outdated
Comment thread internal/cmd/instances.go Outdated
@craciunoiuc

Copy link
Copy Markdown
Contributor

@nurof3n tests failing 😳

Also please close copilot comments which no longer apply

Looks much leaner now 🫦

@nurof3n nurof3n changed the title fix(instances): Handle env variables with key=value, syntax fix(instances): Preserve env variables verbatim Jul 7, 2026
@nurof3n nurof3n changed the title fix(instances): Preserve env variables verbatim fix(instances): Preserve env variables values verbatim Jul 7, 2026
@nurof3n
nurof3n force-pushed the nurof3n/fix/instances-env-sep branch from a8d856f to 937a9a1 Compare July 7, 2026 13:26
@nurof3n
nurof3n requested a review from Copilot July 7, 2026 13:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread internal/resource/value/parse.go Outdated
Comment thread internal/resource/value/parse.go Outdated
Comment thread internal/resource/value/parse_test.go Outdated
Comment thread internal/resource/value/parse.go Outdated
@nurof3n
nurof3n requested review from Copilot, craciunoiuc and jedevc July 8, 2026 11:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.TrimSpace normalization from InstanceService.UnmarshalText. multimetro.ParseKey does 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 --tag shortcut; the existing volume integration only exercises --tag during create, while clone has its own manual patch-to-request path. Please create a source volume, clone it with repeated --tag flags, 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"`

@jedevc
jedevc force-pushed the nurof3n/fix/instances-env-sep branch from e6c6fd6 to 4ceefde Compare August 19, 2026 16:27
craciunoiuc
craciunoiuc previously approved these changes Aug 19, 2026

@craciunoiuc craciunoiuc 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.

All good here. Thanks!

Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.com>
Approved-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.com>

@craciunoiuc

Copy link
Copy Markdown
Contributor

that's a lot of edge cases, now I'm scared there are more 👀

@jedevc

jedevc commented Aug 20, 2026

Copy link
Copy Markdown
Member

The last commit is a pre-existing issue, I can split to a separate PR tbf.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 --tag interface 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 --tags spelling, 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 value test: field= has a non-empty key and adds field: "". 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/--service only 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 --tags form 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 --tag shortcut; existing tag scenarios use it only on create and use --set for edits. Please edit a live instance with repeated --tag, verify the resulting separate tags and exit status, assert that legacy --tags is 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 --tag end to end, inspect/filter for both separate values, verify --tags is 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 --tag shortcut 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 --tags spelling 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))
	})

Comment thread internal/resource/patch/visual.go Outdated
Comment on lines +345 to +347
data, err := yaml.Marshal(v)
if err != nil {
return map[string]any{}
@craciunoiuc

Copy link
Copy Markdown
Contributor

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

@jedevc
jedevc force-pushed the nurof3n/fix/instances-env-sep branch from 70f937d to f607120 Compare August 20, 2026 07:42
@craciunoiuc

Copy link
Copy Markdown
Contributor

There are some weird comments but today I feel like that sugar should not be hoisted on the chopping block

PR looks ok, I'm testing this cool extension and then reporting what it found

image

@craciunoiuc

Copy link
Copy Markdown
Contributor

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?

@jedevc

jedevc commented Aug 20, 2026

Copy link
Copy Markdown
Member

Let's fix it separately, yes. I'll pin it down in x.

@craciunoiuc craciunoiuc 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.

All good here. Thanks!

Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.com>
Approved-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.com>

nurof3n and others added 5 commits August 20, 2026 11:50
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>
@jedevc
jedevc force-pushed the nurof3n/fix/instances-env-sep branch from f607120 to c82c772 Compare August 20, 2026 10:50

@craciunoiuc craciunoiuc 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.

All good here. Thanks!

Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.com>
Approved-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.com>

@jedevc
jedevc merged commit 630b331 into prod-staging Aug 20, 2026
13 checks passed
@jedevc
jedevc deleted the nurof3n/fix/instances-env-sep branch August 20, 2026 17:03
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.

4 participants