Skip to content

Conversation

ned1313
Copy link

@ned1313 ned1313 commented Jul 5, 2025

Description

This PR updates the vault_kv_secret_v2 resource to correctly populate the data_json attribute.

The issue was readResp.Data which is a map[string]interface{} that contains the actual secret data, but the code was trying to marshal [data.Data] which is a [types.Map] (Terraform Framework type). Rather than throw an error, the resulting marshalled JSON was empty {}. The updated code marshals readResp.Data instead to populate the data_json attribute.

Closes #2520

Checklist

  • Added CHANGELOG entry (only for user-facing changes)
  • Acceptance tests where run against all supported Vault Versions

Output from acceptance testing:

$ TESTARGS="--run TestAccKVV2Secret" make testacc
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test --run TestAccKVV2Secret -timeout 30m ./...
?       github.com/hashicorp/terraform-provider-vault   [no test files]
?       github.com/hashicorp/terraform-provider-vault/cmd/coverage      [no test files]
?       github.com/hashicorp/terraform-provider-vault/cmd/generate      [no test files]
ok      github.com/hashicorp/terraform-provider-vault/codegen   (cached) [no tests to run]
?       github.com/hashicorp/terraform-provider-vault/helper    [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/consts   [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/framework/base[no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/framework/client       [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/framework/errutil      [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/framework/model[no test files]
ok      github.com/hashicorp/terraform-provider-vault/internal/framework/validators   (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/internal/identity/entity(cached) [no tests to run]
?       github.com/hashicorp/terraform-provider-vault/internal/identity/group[no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/identity/mfa  [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/pki      [no test files]
ok      github.com/hashicorp/terraform-provider-vault/internal/provider (cached) [no tests to run]
?       github.com/hashicorp/terraform-provider-vault/internal/provider/fwprovider    [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/providertest  [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/rotation [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/sync     [no test files]
ok      github.com/hashicorp/terraform-provider-vault/internal/vault/secrets/ephemeral        1.527s
ok      github.com/hashicorp/terraform-provider-vault/internal/vault/sys     (cached) [no tests to run]
?       github.com/hashicorp/terraform-provider-vault/schema    [no test files]
ok      github.com/hashicorp/terraform-provider-vault/testutil  (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/util      (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/util/mountutil    (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/vault     (cached) [no tests to run]
...

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.

  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.

  • If applicable, I've documented the impact of any changes to security controls.

    Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.

@ned1313 ned1313 requested a review from a team as a code owner July 5, 2025 13:34
@ned1313 ned1313 requested a review from kiannaquach July 5, 2025 13:34
@octo
Copy link

octo commented Jul 31, 2025

@kiannaquach I noticed this PR has been open for a while. My team recently encountered this exact bug, which caused significant debugging time for us. Since the fix appears straightforward, well-documented, and includes tests, I'm curious if there's anything specific holding up the review process or if there's any way I can help move this PR forward? We'd really appreciate having this resolved in an upcoming release.

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.

[Bug]: vault_kv_secret_v2 attribute data_json is not populated
2 participants