Skip to content

Update pki_secret_backend_crl_config to be more resilent to unknown response fields - #2429

Merged
stevendpclark merged 2 commits into
mainfrom
stevendpclark/crl-config-more-resilient
Mar 12, 2025
Merged

Update pki_secret_backend_crl_config to be more resilent to unknown response fields#2429
stevendpclark merged 2 commits into
mainfrom
stevendpclark/crl-config-more-resilient

Conversation

@stevendpclark

@stevendpclark stevendpclark commented Mar 12, 2025

Copy link
Copy Markdown
Contributor

Description

Do not pass in the PKI CRL configuration response map directly into util.SetResourceData as this will fail if an unknown field is returned from Vault that isn't listed in the resource's schema. We encountered this within the Vault 1.19 release where the resource broke when max_crl_entries was added.

│ Error: error setting resource data for key "max_crl_entries", err=Invalid address to set: []string{"max_crl_entries"}
│
│   with vault_pki_secret_backend_crl_config.crl_config,
│   on main.tf line 8, in resource "vault_pki_secret_backend_crl_config" "crl_config":
│    8: resource "vault_pki_secret_backend_crl_config" "crl_config" {

Also this includes a slight refactoring to update the methods to the non-deprecated values along with removing duplication by adding a common method that builds up the list of fields based on Vault version.

Checklist

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

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccXXX'

...

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

@stevendpclark stevendpclark self-assigned this Mar 12, 2025
@stevendpclark
stevendpclark requested a review from a team as a code owner March 12, 2025 16:36
}
}

if err := util.SetResourceData(d, config.Data); err != nil {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the main fix here, passing in config.Data into util.SetResourceData was causing issues when the Data map contained an unknown field

@stevendpclark
stevendpclark merged commit 6ae02e0 into main Mar 12, 2025
@stevendpclark
stevendpclark deleted the stevendpclark/crl-config-more-resilient branch March 12, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants