Skip to content

[LIB+CLI] Add flag to explicitly preserve null values in merge - #4746

Merged
efiacor merged 14 commits into
kptdev:mainfrom
nokia:merge3-preserve-explicit-null
Sep 24, 2026
Merged

efiacor merged 14 commits into
kptdev:mainfrom
nokia:merge3-preserve-explicit-null

Conversation

@mozesl-nokia

@mozesl-nokia mozesl-nokia commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #4745

Added a new flag that allows you to explicitly preserve null values during merge3/update/upgrade.

The use-case for this is packages that are already meant to be patches themselves. Calling the current merge3 flow on such packages can cause the null to get cleared or overridden unintentionally, leading to "combination packages" to inconsistently remove/not remove values.

Default behaviour is unchanged.

The flag is supported by the kpt update command as well, which is persisted into the Kptfile.

AI disclosure: Cursor's Grok 4.6 and Claude Sonnet 5 were used for analysis and most of the implementation

@netlify

netlify Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit 6f34b23
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/6ab4f11b0706010007a8d80a
😎 Deploy Preview https://deploy-preview-4746--kptdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Assisted-by: Cursor:claude-sonnet-5
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Assisted-by: Cursor:claude-sonnet-5
Assisted-by: Cursor:grok-4.6
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
@mozesl-nokia
mozesl-nokia force-pushed the merge3-preserve-explicit-null branch from 8027e4a to 81c7c90 Compare September 15, 2026 13:18
@mozesl-nokia
mozesl-nokia marked this pull request as ready for review September 15, 2026 13:19
@mozesl-nokia
mozesl-nokia requested review from a team September 15, 2026 13:19
@mozesl-nokia
mozesl-nokia requested a balanced review from Copilot September 15, 2026 13:20
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
@mozesl-nokia mozesl-nokia added area/fn-runtime KRM function runtime go Pull requests that update Go code area/api labels Sep 15, 2026

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.

🟡 Changes recommended

Associative lists and the kptops.PkgUpdate path do not honor the new persisted setting.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds opt-in preservation of explicit YAML null values during resource-merge updates.

Changes:

  • Propagates and persists preserveExplicitNull.
  • Updates merge3 behavior and CLI support.
  • Adds fixtures, tests, documentation, and API dependency updates.
File summaries
File Description
pkg/lib/update/updatetypes/updatetypes.go Adds merge option.
pkg/lib/update/update.go Persists and propagates the option.
pkg/lib/update/update_test.go Tests Kptfile persistence.
pkg/lib/update/testdata/keep-tagged-null-preserve/updated/Kptfile Updated fixture metadata.
pkg/lib/update/testdata/keep-tagged-null-preserve/updated/configmap.yaml Updated resource fixture.
pkg/lib/update/testdata/keep-tagged-null-preserve/origin/Kptfile Origin fixture metadata.
pkg/lib/update/testdata/keep-tagged-null-preserve/origin/configmap.yaml Origin resource fixture.
pkg/lib/update/testdata/keep-tagged-null-preserve/expected/Kptfile Expected fixture metadata.
pkg/lib/update/testdata/keep-tagged-null-preserve/expected/configmap.yaml Expected preserved-null output.
pkg/lib/update/testdata/keep-tagged-null-preserve/dest/Kptfile Destination fixture metadata.
pkg/lib/update/testdata/keep-tagged-null-preserve/dest/configmap.yaml Destination null-value fixture.
pkg/lib/update/resource-merge.go Passes the option into merge3.
pkg/lib/update/resource-merge_test.go Tests preserved scalar nulls.
pkg/lib/update/merge3/visitor.go Implements persistent null handling.
pkg/lib/update/merge3/tuple.go Carries the option into visitors.
pkg/lib/update/merge3/merge3.go Extends the merge API.
pkg/lib/update/merge3/merge3_util_test.go Updates existing merge calls.
internal/docs/generated/pkgdocs/docs.go Regenerates CLI documentation.
go.mod Updates the kpt API dependency.
go.sum Updates dependency checksums.
documentation/content/en/reference/cli/pkg/update/_index.md Documents the flag and behavior.
documentation/content/en/guides/3-way-merge.md Documents null preservation.
commands/pkg/update/cmdupdate.go Adds CLI flag handling.
commands/pkg/update/cmdupdate_test.go Tests flag parsing.
Review details
  • Files reviewed: 22/24 changed files
  • Comments generated: 3
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/lib/update/merge3/visitor.go
Comment thread pkg/lib/update/update.go
Comment thread documentation/content/en/reference/cli/pkg/update/_index.md Outdated
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Assisted-by: Cursor:grok-4.6
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Assisted-by: Cursor:grok-4.6
@mozesl-nokia

Copy link
Copy Markdown
Contributor Author

Before merging this, it is probably a good idea to create a new tag for the api module and use that in go.mod, not the commit version.

@liamfallon

Copy link
Copy Markdown
Contributor

Before merging this, it is probably a good idea to create a new tag for the api module and use that in go.mod, not the commit version.

There's already a redirect in the go.mod following the merge of the regexp PR yesterday so I think we should do an API release soon. We can go ahead and merge this one anyway because we'll have to raise a PR on kpt anyway to remove redirect.

Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
77.8% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@efiacor
efiacor merged commit d9d35bd into kptdev:main Sep 24, 2026
27 checks passed
@mozesl-nokia
mozesl-nokia deleted the merge3-preserve-explicit-null branch September 24, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api area/fn-runtime KRM function runtime go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants