Skip to content

fix(appset): parse a child generator selector after interpolation (#17610) - #31245

Open
Indian-boult wants to merge 1 commit into
argoproj:masterfrom
Indian-boult:fix/appset-selector-after-interpolation
Open

Indian-boult wants to merge 1 commit into
argoproj:masterfrom
Indian-boult:fix/appset-selector-after-interpolation

Conversation

@Indian-boult

@Indian-boult Indian-boult commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #17610

Transform in generator_spec_processor.go interpolates the second generator of a matrix with the params of the first one, but it parsed the post selector from the raw spec before that and filtered with it afterwards. A templated key such as enabledIn.{{ .env }} failed to parse as a label key, which failed the whole ApplicationSet with the error in the issue. A templated value parsed but never matched, so Applications were left out with no error.

The selector is now parsed from the interpolated generator, right before the params are generated and filtered. Generators that get no params from a matrix are not interpolated, so their selectors work as before.

TestTransformInterpolatesSelectorWithMatrixParams covers a templated key, a templated matchExpressions value and a templated matchLabels value. All three cases fail on master and pass with this change. I ran all applicationset/... tests, go build ./..., and golangci-lint v2.15.0 on applicationset/..., which reports no new issues. I did not run the full root test suite locally.

#22266 and #22267 edit the same file for nested matrix generators, #22051, which is a different bug.

The same code is in release-3.4, release-3.5 and release-3.6.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Title of the PR
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

Summary by CodeRabbit

  • Bug Fixes
    • Generator selectors now correctly account for interpolated matrix parameters when filtering results. This ensures templated selector keys and values are applied before matching, so generated results include only the elements that satisfy the resolved selector.

…goproj#17610)

Transform interpolates the second generator of a matrix with the first
generator's params, but it parsed the post selector from the raw spec
and filtered with that. A selector that used those params either failed
to parse, which failed the whole ApplicationSet, or never matched, so
Applications were silently left out.

The selector is now parsed from the interpolated generator.

Signed-off-by: Neeraj Khatri <neeraj.khatri.work@gmail.com>
@Indian-boult
Indian-boult requested a review from a team as a code owner November 24, 2026 16:05
@bunnyshell

bunnyshell Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

❗ Preview Environment deployment failed on Bunnyshell

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🚀 /bns:deploy to redeploy the environment
  • ❌ /bns:delete to remove the environment

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Transform now parses each selector after generator parameter interpolation and filters elements using that interpolated selector. Tests cover templated selector keys and values in MatchExpressions and MatchLabels.

Changes: Selector interpolation

Layer / File(s) Summary
Interpolate and apply selectors
applicationset/generators/generator_spec_processor.go, applicationset/generators/generator_spec_processor_test.go
Transform parses selectors after parameter interpolation and filters with the interpolated selector. Tests cover templated MatchExpressions keys and values, and MatchLabels values.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: crenshaw-dev, blakepettersson, ppapapetrou76

Merge Risk: Minimal · up to 224f1

This change lets matrix child generators use parameters from the first generator in their post-selectors. No concrete merge-blocking risk was identified, and the new tests cover the templated key and value cases.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix and the area it touches: the child generator selector in an ApplicationSet matrix is now parsed after parameter interpolation. It matches the main change in the summary and obj…
Description check Passed The description follows the repository template. It states the bug, the fix, and the test coverage, and it links the issue with 'Fixes #17610'. Checked items cover the bug-fix classification, DCO sign…
Linked Issues check Passed [#17610] The request is that a matrix child generator's post-selector can use parameters from the other child generator, including a templated matchExpressions key or value. At the reviewed head, Tran…
Out of Scope Changes check Passed All changes are in applicationset/generators/generator_spec_processor.go and generator_spec_processor_test.go. The production change moves the selector parse into the generator loop after interpolatio…
Full details: Title check

Explanation

The title names the fix and the area it touches: the child generator selector in an ApplicationSet matrix is now parsed after parameter interpolation. It matches the main change in the summary and objectives, and it carries the issue number. It is specific enough for a teammate scanning history to understand the primary change.

Full details: Description check

Explanation

The description follows the repository template. It states the bug, the fix, and the test coverage, and it links the issue with 'Fixes #17610'. Checked items cover the bug-fix classification, DCO sign-off, unit tests, the title convention, and the backport note. Unchecked items are CLI/UI exposure, documentation updates, build status, feature status, and USERS.md. These do not apply to a bug fix with no user-facing feature change, and the build status is not yet confirmed. The description is mostly complete.

Full details: Linked Issues check

Explanation

[#17610] The request is that a matrix child generator's post-selector can use parameters from the other child generator, including a templated matchExpressions key or value. At the reviewed head, Transform in applicationset/generators/generator_spec_processor.go interpolates the second generator with genParams (InterpolateGenerator) and then parses the selector from interpolatedGenerator.Selector (utils.LabelSelectorAsSelector) before GenerateParams and filtering. The filter also checks interpolatedGenerator.Selector. This removes the earlier parse of the raw, uninterpolated selector, which caused the reported 'error parsing label selector' failure. A templated value no longer fails to match because the filter uses the interpolated selector. The new test TestTransformInterpolatesSelectorWithMatrixParams in generator_spec_processor_test.go covers a templated key, a templated matchExpressions value and a templated matchLabels value, and asserts that only the matching element is returned. I did not execute the test. I also did not inspect the render code (RenderGeneratorParams); the path applicationset/utils/render.go does not exist at the reviewed head, so I could not confirm directly that the Selector field is rendered. The test case exercises that path through Transform, and the author reports it fails on master.

Full details: Out of Scope Changes check

Explanation

All changes are in applicationset/generators/generator_spec_processor.go and generator_spec_processor_test.go. The production change moves the selector parse into the generator loop after interpolation and changes the filter to use interpolatedGenerator.Selector. The error return and message are unchanged. The test function is directly tied to issue #17610. No unrelated files or behavior changes appear in the whole-PR diff against the merge base b6f354e.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 21977766-89cb-4e59-aa38-e2c12b5dc3e7
Commits

Reviewing files that changed from the base of the PR and between b6f354e and 224f17b.

Files selected for processing: 2

  • applicationset/generators/generator_spec_processor.go
  • applicationset/generators/generator_spec_processor_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 73.70%. Comparing base (b6f354e) to head (224f17b).

Files with missing lines Patch % Lines
...licationset/generators/generator_spec_processor.go 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #31245      +/-   ##
==========================================
+ Coverage   73.69%   73.70%   +0.01%     
==========================================
  Files         444      444              
  Lines       58261    58261              
==========================================
+ Hits        42936    42943       +7     
+ Misses      15325    15318       -7     
Flag Coverage Δ
e2e 30.77% <75.00%> (+0.02%) ⬆️
unit-tests 69.74% <75.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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.

The matchExpressions selector in a git generator, part of a matrix generator, cannot use parameters from the other generator with goTemplate: true

1 participant