-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test assertion errors suppress values even with nonsensitive() #35961
Comments
Hi @xyl0o, thanks for filing this! I'll just note this behaviour isn't unique to the testing framework. All custom condition checks (including test assertions, pre and post conditions, variable validations, and check blocks) show the same behaviour. The With that in mind, I don't believe this is a bug as the everything is working as intended. However, I do think it could be valuable for the testing framework to be able expose sensitive variables when requested by the user. The testing framework is likely to be using dummy values anyway, and allowing the user easier access to debug values is useful. I'm going to recategorise this as an enhancement request rather than a bug. We'll have to think about the best way to allow the exposure of sensitive values in test files, as I wouldn't want to modify the behaviour of the other custom conditions as an accidental side effect of this. |
Why isn't the error message showing that new value? I wouldn't necessary scope this just to Nonetheless if this is improved just for |
The output of functions called inside an expression are not available externally. Terraform simply doesn't have access to the nonsensitive value returned by the In regular Terraform, you can work around this by aliasing the nonsensitive value outside of the expression and then using that. locals {
nonsensitive = nonsensitive(var.sensitive)
}
resource "type" "name" {
lifecycle {
postcondition {
condition = var.nonsensitive == "something"
error_message = "wrong value"
}
}
} This currently isn't possible within the testing framework, as there is no way to perform intermediary processing of values from within the module. We do have an existing feature request for local blocks within test files: #34629. It is possible that implementing that would help with this somewhat, but leaving this ticket open would allow us to see if there is more interest in a more targeted solution. |
Terraform Version
Terraform Configuration Files
Debug Output
https://gist.github.com/xyl0o/8302b1e48630543b4b21fcf4b50a13db
Expected Behavior
The failed assertion doesn't print values that are sensitive:
But I'd expect to be able to see the value of both operands when using
nonsensitive()
- so something like this:Actual Behavior
Using
nonsensitive()
has no effect:Steps to Reproduce
terraform test --filter tests/sensitive_values.tftest.hcl
Additional Context
No response
References
No response
The text was updated successfully, but these errors were encountered: