Commit f38d744
committed
internal/provider: fix required tag validation crash
Previously the validate required tags interceptor would crash when the planned value for the `tags` attribute included unknown tag values. Validation now skips when planned values are not wholly known.
Without the patch:
```console
% go test -count=1 ./internal/provider/framework/... -run Test_resourceValidateRequiredTagsInterceptor
--- FAIL: Test_resourceValidateRequiredTagsInterceptor (0.00s)
--- FAIL: Test_resourceValidateRequiredTagsInterceptor/create,_unknown_tag_values (0.00s)
--- FAIL: Test_resourceValidateRequiredTagsInterceptor (0.00s)
--- FAIL: Test_resourceValidateRequiredTagsInterceptor/update,_unknown_tag_values (0.00s)
panic: Value Conversion Error
An unexpected error was encountered trying to build a value. This is always an error in the provider. Please report the following to the provider developer:
Received unknown value, however the target type cannot handle unknown values. Use the corresponding `types` package type or a custom type that handles unknown values.
Path: ["foo"]
Target Type: *string
Suggested Type: basetypes.StringValue
["foo"] [recovered]
panic: Value Conversion Error
An unexpected error was encountered trying to build a value. This is always an error in the provider. Please report the following to the provider developer:
Received unknown value, however the target type cannot handle unknown values. Use the corresponding `types` package type or a custom type that handles unknown values.
Path: ["foo"]
Target Type: *string
Suggested Type: basetypes.StringValue
["foo"]
goroutine 28 [running]:
testing.tRunner.func1.2({0x101701aa0, 0x14001282150})
/Users/jaredbaker/sdk/go1.24.10/src/testing/testing.go:1734 +0x1ac
testing.tRunner.func1()
/Users/jaredbaker/sdk/go1.24.10/src/testing/testing.go:1737 +0x334
panic({0x101701aa0?, 0x14001282150?})
/Users/jaredbaker/sdk/go1.24.10/src/runtime/panic.go:792 +0x124
github.com/hashicorp/terraform-provider-aws/internal/errs.Must[...](...)
/Users/jaredbaker/development/_worktrees/b-tag-policy-interceptor/internal/errs/must.go:13
github.com/hashicorp/terraform-provider-aws/internal/errs/fwdiag.Must[...]({0x0?, 0x0}, {0x14001280920, 0x1016b17a0?, 0x1400009a298?})
/Users/jaredbaker/development/_worktrees/b-tag-policy-interceptor/internal/errs/fwdiag/must.go:17 +0x58
github.com/hashicorp/terraform-provider-aws/internal/framework/flex.must(...)
/Users/jaredbaker/development/_worktrees/b-tag-policy-interceptor/internal/framework/flex/errs.go:13
github.com/hashicorp/terraform-provider-aws/internal/framework/flex.ExpandFrameworkStringMap({0x1017c9e08, 0x140011020c0}, {0x1017cea10, 0x1400138c1c0})
/Users/jaredbaker/development/_worktrees/b-tag-policy-interceptor/internal/framework/flex/map.go:17 +0x94
github.com/hashicorp/terraform-provider-aws/internal/tags.New({0x1017c9e08, 0x140011020c0}, {0x101795120?, 0x1400110dd68})
/Users/jaredbaker/development/_worktrees/b-tag-policy-interceptor/internal/tags/key_value_tags.go:650 +0x2fc
github.com/hashicorp/terraform-provider-aws/internal/provider/framework.resourceValidateRequiredTagsInterceptor.modifyPlan({}, {0x1017c9e08, 0x140011020c0}, {{0x1017cfb58, 0x14000aec160}, 0x140000fc700, 0x14001049580, 0x1})
/Users/jaredbaker/development/_worktrees/b-tag-policy-interceptor/internal/provider/framework/tags_interceptor.go:308 +0x4d8
github.com/hashicorp/terraform-provider-aws/internal/provider/framework.Test_resourceValidateRequiredTagsInterceptor.func2(0x14000003c00)
/Users/jaredbaker/development/_worktrees/b-tag-policy-interceptor/internal/provider/framework/tags_interceptor_test.go:404 +0x16c
testing.tRunner(0x14000003c00, 0x14001063570)
/Users/jaredbaker/sdk/go1.24.10/src/testing/testing.go:1792 +0xe4
created by testing.(*T).Run in goroutine 24
/Users/jaredbaker/sdk/go1.24.10/src/testing/testing.go:1851 +0x374
FAIL github.com/hashicorp/terraform-provider-aws/internal/provider/framework 0.850s
```
```console
% TF_ACC_REQUIRED_TAG_KEY=Owner make t K=iot T=TestAccIoTBillingGroup_requiredTags && TF_ACC_REQUIRED_TAG_KEY=Owner make t K=logs T=TestAccLogsLogGroup_requiredTags
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
make: Running acceptance tests on branch: 🌿 b-tag-policy-interceptor 🌿...
TF_ACC=1 go1.24.10 test ./internal/service/iot/... -v -count 1 -parallel 20 -run='TestAccIoTBillingGroup_requiredTags' -timeout 360m -vet=off
2025/11/21 11:54:39 Creating Terraform AWS Provider (SDKv2-style)...
2025/11/21 11:54:39 Initializing Terraform AWS Provider (SDKv2-style)...
--- PASS: TestAccIoTBillingGroup_requiredTags_defaultTags (19.31s)
--- PASS: TestAccIoTBillingGroup_requiredTags (19.33s)
--- PASS: TestAccIoTBillingGroup_requiredTags_disabled (34.01s)
--- PASS: TestAccIoTBillingGroup_requiredTags_warning (37.18s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/iot 43.681s
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
make: Running acceptance tests on branch: 🌿 b-tag-policy-interceptor 🌿...
TF_ACC=1 go1.24.10 test ./internal/service/logs/... -v -count 1 -parallel 20 -run='TestAccLogsLogGroup_requiredTags' -timeout 360m -vet=off
2025/11/21 11:55:37 Creating Terraform AWS Provider (SDKv2-style)...
2025/11/21 11:55:37 Initializing Terraform AWS Provider (SDKv2-style)...
--- PASS: TestAccLogsLogGroup_requiredTags (19.59s)
--- PASS: TestAccLogsLogGroup_requiredTags_defaultTags (19.67s)
--- PASS: TestAccLogsLogGroup_requiredTags_disabled (35.34s)
--- PASS: TestAccLogsLogGroup_requiredTags_warning (38.32s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/logs 44.717s
```1 parent 2c53338 commit f38d744
File tree
4 files changed
+215
-0
lines changed- .changelog
- internal/provider
- framework
- sdkv2
4 files changed
+215
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
304 | 308 | | |
305 | 309 | | |
306 | 310 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
100 | 130 | | |
101 | 131 | | |
102 | 132 | | |
| |||
135 | 165 | | |
136 | 166 | | |
137 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
138 | 255 | | |
139 | 256 | | |
140 | 257 | | |
| |||
162 | 279 | | |
163 | 280 | | |
164 | 281 | | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
165 | 369 | | |
166 | 370 | | |
167 | 371 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
332 | 336 | | |
333 | 337 | | |
334 | 338 | | |
| |||
0 commit comments