Skip to content

Exclude fn-config from owning function's input in fn render - #4673

Merged
aravindtga merged 2 commits into
kptdev:mainfrom
Nordix:fn-render-exclude-own-fnconfig
Aug 12, 2026
Merged

Exclude fn-config from owning function's input in fn render#4673
aravindtga merged 2 commits into
kptdev:mainfrom
Nordix:fn-render-exclude-own-fnconfig

Conversation

@aravindtga

Copy link
Copy Markdown
Contributor

Description

When kpt fn render executes a pipeline, function configs specified via configPath were included in resourceList.items for their owning function. This allowed functions to mutate their own configuration, violating the documented contract that configPath resources should only be accessible via resourceList.functionConfig.

This change excludes a function's own configPath resource from its input items during fn render, matching the behavior already implemented for fn eval in PR #4639. The fn-config remains visible to other functions in the pipeline (it is only excluded from its owning function).

What changed

  • runMutators: Before executing each mutator, its configPath resource is removed from the input list using slices.DeleteFunc. It is added back unmodified after execution so subsequent functions can still see it and the file is not pruned from disk.

  • runValidators: Same exclusion using slices.Clone + slices.DeleteFunc to create a filtered copy (original input stays intact since validators don't modify it).

Related Issue(s)

Type of Change

  • Bug fix
  • Tests

Checklist

  • Code follows project style guidelines
  • Self-reviewed changes
  • Tests added/updated
  • Documentation added/updated
  • All tests and gating checks pass

AI Disclosure

  • I have used AI in the creation of this PR.

If so, please describe how:
- Kiro to analyse the issue, validate the fix, generate unit/E2E tests and draft PR message.

@netlify

netlify Bot commented Jul 30, 2026

Copy link
Copy Markdown

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit 1b2d8f2
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/6a7b33403f063000076ce4e0
😎 Deploy Preview https://deploy-preview-4673--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.

@aravindtga aravindtga self-assigned this Jul 30, 2026
@aravindtga
aravindtga force-pushed the fn-render-exclude-own-fnconfig branch 2 times, most recently from 0781cc8 to 8c76035 Compare July 30, 2026 15:22
@liamfallon
liamfallon requested a review from Copilot July 30, 2026 15:24

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.

Pull request overview

Aligns kpt fn render with the documented function contract by ensuring a function’s own configPath resource is not included in resourceList.items for that function (it should only be provided via resourceList.functionConfig), matching the behavior previously implemented for fn eval.

Changes:

  • Updated render pipeline execution to exclude a mutator/validator’s own configPath resource from its input items while keeping it available to other functions.
  • Added unit tests validating fn-config exclusion behavior (including nested packages and error paths) and updated fn-render e2e expected diffs.
  • Updated documentation and API comments to describe the refined configPath contract.

Reviewed changes

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

Show a summary per file
File Description
pkg/lib/kptops/render_executor.go Filters out the owning function’s configPath resource from its input items during render execution (mutators/validators).
pkg/lib/kptops/render_executor_test.go Adds unit tests to assert fn-config exclusion, preservation on disk, nested package behavior, and error restoration.
e2e/testdata/fn-render/modify-path-annotation/.expected/diff.patch Updates expected diff to reflect fn-config no longer being mutated as an input item by its owning function.
e2e/testdata/fn-render/fnconfig/.expected/diff.patch Updates expected output/results counts and removes expected fn-config mutations by the owning function.
e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/.expected/diff.patch Updates expected output/results counts and removes expected fn-config mutations by the owning function.
e2e/testdata/fn-render/fnconfig-in-subdir/.expected/diff.patch Updates expected output/results counts and removes expected fn-config mutations by the owning function.
e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/.expected/diff.patch Updates expected output/results counts and removes expected fn-config mutations by the owning function.
documentation/content/en/book/04-using-functions/_index.md Documents that a function won’t receive its own configPath resource in input items.
api/kptfile/v1/types.go Updates ConfigPath field comment to match the new contract.

Comment thread pkg/lib/kptops/render_executor.go
Comment thread pkg/lib/kptops/render_executor.go Outdated
Comment thread api/kptfile/v1/types.go
@aravindtga
aravindtga marked this pull request as ready for review July 30, 2026 16:16
@aravindtga
aravindtga requested review from a team July 30, 2026 16:16
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working go Pull requests that update Go code labels Jul 30, 2026
@aravindtga
aravindtga marked this pull request as draft July 30, 2026 16:33
@aravindtga
aravindtga marked this pull request as ready for review July 30, 2026 16:33
@dosubot dosubot Bot added the lgtm label Aug 5, 2026
Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
@aravindtga
aravindtga force-pushed the fn-render-exclude-own-fnconfig branch 2 times, most recently from 55b088a to c297bee Compare August 5, 2026 16:23
@sonarqubecloud

sonarqubecloud Bot commented Aug 5, 2026

Copy link
Copy Markdown

@liamfallon

Copy link
Copy Markdown
Contributor

As this is a behavioural change please ask @mozesl-nokia to review this PR.

@aravindtga
aravindtga requested a review from a team August 7, 2026 08:48
Comment thread pkg/lib/kptops/render_executor.go Outdated
Comment thread pkg/lib/kptops/render_executor_test.go Outdated
Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
@aravindtga
aravindtga force-pushed the fn-render-exclude-own-fnconfig branch from c297bee to 1b2d8f2 Compare August 11, 2026 14:35
@aravindtga
aravindtga merged commit bc12f9b into kptdev:main Aug 12, 2026
29 checks passed
@aravindtga
aravindtga deleted the fn-render-exclude-own-fnconfig branch August 12, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update Go code lgtm size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transform functions should bypass functionConfigs

5 participants