Skip to content

Commit 47beda9

Browse files
authored
nonsensitive: no longer produces error when applied to nonsensitive values (#33856)
* Proposing fix to #31693 (not always possible to apply nonsensitive) #31693 * #31693 not always possible to apply nonsensitive updated documentation * Update sensitive_test.go Fixing tests * Corrections as per #33856 (comment)
1 parent 7e34ef8 commit 47beda9

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

internal/lang/funcs/sensitive.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ var NonsensitiveFunc = function.New(&function.Spec{
5252
return args[0].Type(), nil
5353
},
5454
Impl: func(args []cty.Value, retType cty.Type) (ret cty.Value, err error) {
55-
if args[0].IsKnown() && !args[0].HasMark(marks.Sensitive) {
56-
return cty.DynamicVal, function.NewArgErrorf(0, "the given value is not sensitive, so this call is redundant")
57-
}
5855
v, m := args[0].Unmark()
5956
delete(m, marks.Sensitive) // remove the sensitive marking
6057
return v.WithMarks(m), nil

internal/lang/funcs/sensitive_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,16 @@ func TestNonsensitive(t *testing.T) {
130130
``,
131131
},
132132

133-
// Passing a value that is already non-sensitive is an error,
134-
// because this function should always be used with specific
135-
// intention, not just as a "make everything visible" hammer.
133+
// Passing a value that is already non-sensitive is not an error,
134+
// as this function may be used with specific to ensure that all
135+
// values are indeed non-sensitive
136136
{
137137
cty.NumberIntVal(1),
138-
`the given value is not sensitive, so this call is redundant`,
138+
``,
139139
},
140140
{
141141
cty.NullVal(cty.String),
142-
`the given value is not sensitive, so this call is redundant`,
142+
``,
143143
},
144144

145145
// Unknown values may become sensitive once they are known, so we

website/docs/language/functions/nonsensitive.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,8 @@ due to an inappropriate call to `nonsensitive` in your module, that's a bug in
7373
your module and not a bug in Terraform itself.
7474
**Use this function sparingly and only with due care.**
7575

76-
`nonsensitive` will return an error if you pass a value that isn't marked
77-
as sensitive, because such a call would be redundant and potentially confusing
78-
or misleading to a future maintainer of your module. Use `nonsensitive` only
79-
after careful consideration and with definite intent.
76+
`nonsensitive` will make no changes to values that aren't marked as sensitive, even though such a call may be redundant and potentially confusing.
77+
Use `nonsensitive` only after careful consideration and with definite intent.
8078

8179
Consider including a comment adjacent to your call to explain to future
8280
maintainers what makes the usage safe and thus what invariants they must take

0 commit comments

Comments
 (0)