Skip to content

secretmanager: fixed secret_data/secret_data_wo constraint allowing neither to be set#18320

Open
malhotrasagar2212 wants to merge 2 commits into
GoogleCloudPlatform:mainfrom
malhotrasagar2212:Fix_Google_Secret_Version_Payload_error
Open

secretmanager: fixed secret_data/secret_data_wo constraint allowing neither to be set#18320
malhotrasagar2212 wants to merge 2 commits into
GoogleCloudPlatform:mainfrom
malhotrasagar2212:Fix_Google_Secret_Version_Payload_error

Conversation

@malhotrasagar2212

@malhotrasagar2212 malhotrasagar2212 commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

google_secret_manager_secret_version accepted a config with neither secret_data nor secret_data_wo set. terraform planned it successfully, created the parent secret , then failed at apply with an API error naming a field that doesn't exist in the provider:
Error: Error creating SecretVersion: googleapi: Error 400: Field [payload] is required.

Fixes hashicorp/terraform-provider-google#24269
Release Note Template for Downstream PRs (will be copied)

See Write release notes for guidance.

secretmanager: fixed an issue where `google_secret_manager_secret_version` would fail at apply time with `Field [payload]` is required if neither `secret_data` or `secret_data_wo` was set. The provider  now returns a validation error at plan time.

@modular-magician

modular-magician commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit e2f8f34:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 2 files changed, 49 insertions(+), 12 deletions(-)
google-beta provider View Diff 2 files changed, 49 insertions(+), 12 deletions(-)
terraform-google-conversion View Diff 2 files changed, 15 insertions(+), 12 deletions(-)

Breaking Change(s) Detected

The following breaking change(s) were detected within your pull request.

  • Field secret_data_wo within resource google_secret_manager_secret_version was added to exactly one of - reference
  • Field secret_data within resource google_secret_manager_secret_version was added to exactly one of - reference

If you believe this detection to be incorrect please raise the concern with your reviewer.
If you intend to make this change you will need to wait for a major release window.
An override-breaking-change label can be added to allow merging.

Test report

Analytics

Total Tests Passed Skipped Affected
47 42 4 1
Affected Service Packages
  • secretmanager

Learn how VCR tests work


Step 1: Replaying Mode

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit.

Click here to see the affected tests
  • TestAccSecretManagerSecretVersion_neitherSecretDataSet

View the replaying VCR build log


Step 2: Recording Mode

Recording Mode Replaying Rerun Test Name
✅ Log ❌ Error · Log TestAccSecretManagerSecretVersion_neitherSecretDataSet

Caution

Issues requiring attention before PR completion

🔴 Replaying Rerun Failed: Some tests failed due to non-determinism when VCR replayed the response. See the table above for details.

Please address these issues to complete your PR. If you believe these detections are incorrect or unrelated to your change, please raise the concern with your reviewer.

View the recording VCR build log or the debug logs folder for detailed results.

@malhotrasagar2212, @melinath VCR tests complete for e2f8f34!

@melinath melinath added the override-breaking-change Allows a potential breaking change to be merged label Jul 17, 2026

@melinath melinath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - just to double check, were you still able to reproduce the error from the API?

attn @BBBmau FYI since this will impact #18309

@melinath

Copy link
Copy Markdown
Member

FYI the new test is impacted by hashicorp/terraform-provider-google#15427 & should probably be marked as SkipIfVcr to avoid confusion.

@BBBmau BBBmau left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@melinath This PR was actually something I had in mind to open after looking further into the PR i had opened. The old PR can be closed as the actual logic that we want to focus on now is in the writeOnlyField logic that adds the write-only and write-only-version fields.

The suggested changes are to resolve the missing required_with which is due to not properly naming secretDataWoVersion, the FEATURE-BRANCH-major-release-8.0.0 will of course resolve this by using the new write_only: true and not write_only_legacy: true

- 'payload.0.secretData'
- 'payload.0.secretDataWo'
write_only_legacy: true
- name: 'SecretDataWoVersion'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: 'SecretDataWoVersion'
- name: 'secretDataWoVersion'

@@ -213,8 +214,9 @@ properties:
api_name: data
required_with:
- 'SecretDataWoVersion'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 'SecretDataWoVersion'
- 'payload.0.secretDataWoVersion'

@melinath melinath Jul 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change would be a breaking change that's not allowed in a minor release; the breaking change already in this PR is allowed because the resource can't work otherwise, but I don't think that's true for this one.

Comment on lines 215 to 216
required_with:
- 'SecretDataWoVersion'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be deleted for clarity, then re-added in the major release branch.

Suggested change
required_with:
- 'SecretDataWoVersion'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

override-breaking-change Allows a potential breaking change to be merged service/secretmanager

Projects

None yet

Development

Successfully merging this pull request may close these issues.

google_secret_manager_secret_version: Missing 'secret_data' (which is marked optional in documentation) causes "Field [payload] is required" error

4 participants