You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes sensitive map fields behind wildcard paths (e.g. tool[*].config[*].remote_mcp[*].headers) not being resolved from their secret reference.
In storeSensitiveData, the whole-secret (map) branch wrote each key to the raw tfPath, leaving the [*] wildcards unexpanded. Terraform state/params never received the values for these fields. The branch now expands the TF path from the already expanded JSON path via expandedTFPath, as the other branches do.
Run make reviewable to ensure this PR is ready for review.
Added backport release-x.y labels to auto-backport this PR if necessary.
How has this code been tested
Unit test WildcardWithSecretReference in pkg/resource/sensitive_test.go: a headersSecretRef nested under tool[*].config[*].remoteMcp[*] now yields tool[0].config[0].remote_mcp[0].headers = {"Authorization": "Bearer test"}.
Reviewing files that changed from the base of the PR and between e425ccf and f9ad829.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
For whole-Secret map references, storeSensitiveData now resolves an expanded Terraform path before writing each Secret entry. A new test covers a secret reference nested under wildcarded fields.
Changes: Sensitive Map Path Handling
Layer / File(s)
Summary
Expand and validate map paths pkg/resource/sensitive.go, pkg/resource/sensitive_test.go
storeSensitiveData uses the Terraform path resolved from each expanded JSON path and returns mapping errors. The test checks that a secret Authorization entry is placed in the matching nested headers map.
crossplane/upjet issue 810: It describes the same unexpanded wildcard path in the whole-Secret map branch addressed by this change.
Merge Risk: Minimal · previous review e425c
This change fixes whole-Secret map references, such as headersSecretRef, on Terraform paths containing wildcards, so the headers now land in the correct nested map. No concrete regression was established for generated resources. A custom provider mapping that uses an unusual path shape remains a speculative edge case. No action is needed before merging.
Important
Pre-merge checks failed
Please resolve all errors before merging. Addressing warnings is optional.
Failed checks: 3 inconclusive
Check name
Status
Explanation
Resolution
Configuration Api Breaking Changes
Pull request inputs changed after this check was assessed; its verdict is no longer current.
Re-run the check against the current pull request inputs.
Generated Code Manual Edits
Pull request inputs changed after this check was assessed; its verdict is no longer current.
Re-run the check against the current pull request inputs.
Template Breaking Changes
Pull request inputs changed after this check was assessed; its verdict is no longer current.
Re-run the check against the current pull request inputs.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title names the fix: expanding the wildcard TF path for sensitive map secret references. It matches the changeset, which changes the whole-secret map branch in storeSensitiveData to use the expand…
Description check
The description states the bug, the cause (the whole-secret map branch wrote to the raw tfPath), the fix (expandedTFPath), and the added WildcardWithSecretReference test. It relates directly to the ch…
Linked Issues check
Thank you for the focused fix. Issue #2326 is the only active direct link. Its requirement is coding: whole-Secret map references under wildcard paths must store entries at the expanded Terraform path…
Out of Scope Changes check
The supplied summary lists two changed files. pkg/resource/sensitive.go has +6/-2 lines in storeSensitiveData, and pkg/resource/sensitive_test.go has +59 lines for the WildcardWithSecretReference case…
Full details: Title check
Explanation
The title names the fix: expanding the wildcard TF path for sensitive map secret references. It matches the changeset, which changes the whole-secret map branch in storeSensitiveData to use the expanded TF path. It is 59 characters, under the 72-character limit.
Full details: Description check
Explanation
The description states the bug, the cause (the whole-secret map branch wrote to the raw tfPath), the fix (expandedTFPath), and the added WildcardWithSecretReference test. It relates directly to the changeset.
Full details: Linked Issues check
Explanation
Thank you for the focused fix. Issue #2326 is the only active direct link. Its requirement is coding: whole-Secret map references under wildcard paths must store entries at the expanded Terraform path (for example, tool[0].config[0].remote_mcp[0].headers), not fail with "tool is not an object". At the reviewed head, the whole-Secret map branch of storeSensitiveData in pkg/resource/sensitive.go calls expandedTFPath(expandedJSONPath, mapping) and writes each entry to fmt.Sprintf("%s[%s]", expTF, key). This matches the suggested fix in the issue and the approach used by setSensitiveParametersWithPaved. Non-wildcard map paths resolve to the same path, so they remain unaffected. The test case WildcardWithSecretReference in pkg/resource/sensitive_test.go covers the nested headersSecretRef case, per the PR description and the supplied summary. I did not read the test file text directly, because the diff tool returned no text. The coding requirement is met by the source change at head.
Full details: Out of Scope Changes check
Explanation
The supplied summary lists two changed files. pkg/resource/sensitive.go has +6/-2 lines in storeSensitiveData, and pkg/resource/sensitive_test.go has +59 lines for the WildcardWithSecretReference case. Both changes directly implement or test the issue #2326 requirement. The summary reports no changes to exported declarations. The head file shows the expandedTFPath call in the map branch. Limitation: the whole-PR text diff was unavailable, so I could not confirm the exact line-level diff against the merge base. This PASS relies on the supplied summary and the head file contents.
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.
Reviewing files that changed from the base of the PR and between 458b2e0 and e425ccf.
Files selected for processing: 2
pkg/resource/sensitive.go
pkg/resource/sensitive_test.go
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of your changes
Fixes sensitive map fields behind wildcard paths (e.g.
tool[*].config[*].remote_mcp[*].headers) not being resolved from their secret reference.In
storeSensitiveData, the whole-secret (map) branch wrote each key to the rawtfPath, leaving the[*]wildcards unexpanded. Terraform state/params never received the values for these fields. The branch now expands the TF path from the already expanded JSON path viaexpandedTFPath, as the other branches do.Fixes crossplane-contrib/provider-upjet-aws#2326
Added a
WildcardWithSecretReferencecase toTestGetSensitiveParameterscovering a nested wildcard map secret reference.I have:
make reviewableto ensure this PR is ready for review.backport release-x.ylabels to auto-backport this PR if necessary.How has this code been tested
Unit test
WildcardWithSecretReferenceinpkg/resource/sensitive_test.go: aheadersSecretRefnested undertool[*].config[*].remoteMcp[*]now yieldstool[0].config[0].remote_mcp[0].headers = {"Authorization": "Bearer test"}.