Skip to content

Preserve document foot comments across fn render mutators - #4890

Open
Kulraj69 wants to merge 1 commit into
kptdev:mainfrom
Kulraj69:fix-4211-render-comment-dup
Open

Kulraj69 wants to merge 1 commit into
kptdev:mainfrom
Kulraj69:fix-4211-render-comment-dup

Conversation

@Kulraj69

Copy link
Copy Markdown

When a pipeline has several mutators, kyaml's FunctionFilter restores a document's foot comment onto the bare resource root. On the next function call that root is serialized inside the ResourceList items sequence, and YAML decoding attaches the foot comment to the following resource, so each additional mutator duplicated comments across resources and files.

Re-wrap such roots in a document node after each function run so foot comments stay outside the items sequence.

Fixes #4211

Assisted-by: Devin:Claude

When a pipeline has several mutators, kyaml's FunctionFilter restores a
document's foot comment onto the bare resource root. On the next function
call that root is serialized inside the ResourceList items sequence, and
YAML decoding attaches the foot comment to the following resource, so each
additional mutator duplicated comments across resources and files.

Re-wrap such roots in a document node after each function run so foot
comments stay outside the items sequence.

Fixes kptdev#4211

Assisted-by: Devin:Claude
Signed-off-by: Kulraj <59130414+Kulraj69@users.noreply.github.com>
@Kulraj69
Kulraj69 requested review from a team and a balanced review from Copilot November 23, 2026 10:01
@netlify

netlify Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for kptdocs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 255e1c3
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/6b040ef26ed91c0b1fd93681
😎 Deploy Preview https://deploy-preview-4890--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.

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.

🟢 Approval recommended

No active review issues block the change to preserve document foot comments across successive function mutators.

No open issues 🎉

Review effort: Balanced

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

Resources with both head and foot comments retain the header on the child node, leaving the document header empty and allowing later comment-stripping mutators to lose it.

1 open issue

Review effort: Balanced

Comment thread pkg/fn/runtime/runner.go
Comment on lines +390 to +396
content := *root
content.FootComment = ""
node.SetYNode(&yaml.Node{
Kind: yaml.DocumentNode,
FootComment: root.FootComment,
Content: []*yaml.Node{&content},
})
@aravindtga

Copy link
Copy Markdown
Contributor

@Kulraj69 Can you address the comments, So that the maintainers can review this.

@Kulraj69

Copy link
Copy Markdown
Author

Thanks for flagging this. I reproduced the document-header loss when a pass-through function is followed by a comment-stripping function. The private correction moves the header onto the document wrapper along with the footer. The runtime tests pass with the repository-local API replacement; the published API dependency fails to build before those tests, so this is not a default-build or CI pass. The branch has not been updated yet.

@efiacor

efiacor commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Thanks for flagging this. I reproduced the document-header loss when a pass-through function is followed by a comment-stripping function. The private correction moves the header onto the document wrapper along with the footer. The runtime tests pass with the repository-local API replacement; the published API dependency fails to build before those tests, so this is not a default-build or CI pass. The branch has not been updated yet.

Please rebase on main and address copilot comment

This branch has not been deployed

No deployments
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.

kpt fn render execution adds unintended line comments to manifests

4 participants