Skip to content

Expand wildcard TF path for sensitive map secret references - #824

Open
neuro-ng wants to merge 1 commit into
crossplane:mainfrom
neuro-ng:fix/sensitive-map-wildcard-path
Open

neuro-ng wants to merge 1 commit into
crossplane:mainfrom
neuro-ng:fix/sensitive-map-wildcard-path

Conversation

@neuro-ng

Copy link
Copy Markdown

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

Fixes crossplane-contrib/provider-upjet-aws#2326

Added a WildcardWithSecretReference case to TestGetSensitiveParameters covering a nested wildcard map secret reference.

I have:

  • Read and followed Upjet's contribution process.
  • 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"}.

…ossplane-contrib/provider-upjet-aws/issues#2326)

Signed-off-by: Norwen Gonio <neu.gonio@gmail.com>
@neuro-ng
neuro-ng force-pushed the fix/sensitive-map-wildcard-path branch from e425ccf to f9ad829 Compare November 19, 2026 07:00
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

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.

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

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • 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 Failed checks: 3 inconclusive

Check name Status Explanation Resolution
Configuration Api Breaking Changes Inconclusive 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 Inconclusive 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 Inconclusive 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 Passed checks: 4 passed

Check name Status Explanation
Title check Passed 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 Passed 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 Passed 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 Passed 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.

Share

Recent review info

Run configuration

Commits

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.

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.

Harness headersSecretRef fails: "tool is not an object"

1 participant