@@ -193,6 +193,22 @@ func AttributeModifyPlan(ctx context.Context, a fwschema.Attribute, req ModifyAt
193
193
return
194
194
}
195
195
196
+ planObjectValuable , diags := coerceObjectValuable (ctx , attrPath , planElem )
197
+
198
+ resp .Diagnostics .Append (diags ... )
199
+
200
+ if resp .Diagnostics .HasError () {
201
+ return
202
+ }
203
+
204
+ typable , diags := coerceObjectTypable (ctx , attrPath , planObjectValuable )
205
+
206
+ resp .Diagnostics .Append (diags ... )
207
+
208
+ if resp .Diagnostics .HasError () {
209
+ return
210
+ }
211
+
196
212
stateObject , diags := listElemObject (ctx , attrPath , stateList , idx , fwschemadata .DataDescriptionState )
197
213
198
214
resp .Diagnostics .Append (diags ... )
@@ -219,7 +235,26 @@ func AttributeModifyPlan(ctx context.Context, a fwschema.Attribute, req ModifyAt
219
235
220
236
NestedAttributeObjectPlanModify (ctx , nestedAttributeObject , objectReq , objectResp )
221
237
222
- planElements [idx ] = objectResp .AttributePlan
238
+ respValue , diags := coerceObjectValue (ctx , attrPath , objectResp .AttributePlan )
239
+
240
+ resp .Diagnostics .Append (diags ... )
241
+
242
+ if resp .Diagnostics .HasError () {
243
+ return
244
+ }
245
+
246
+ // A custom value type must be returned in the final response to prevent
247
+ // later correctness errors.
248
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/821
249
+ respValuable , diags := typable .ValueFromObject (ctx , respValue )
250
+
251
+ resp .Diagnostics .Append (diags ... )
252
+
253
+ if resp .Diagnostics .HasError () {
254
+ return
255
+ }
256
+
257
+ planElements [idx ] = respValuable
223
258
resp .Diagnostics .Append (objectResp .Diagnostics ... )
224
259
resp .Private = objectResp .Private
225
260
resp .RequiresReplace .Append (objectResp .RequiresReplace ... )
@@ -309,6 +344,22 @@ func AttributeModifyPlan(ctx context.Context, a fwschema.Attribute, req ModifyAt
309
344
return
310
345
}
311
346
347
+ planObjectValuable , diags := coerceObjectValuable (ctx , attrPath , planElem )
348
+
349
+ resp .Diagnostics .Append (diags ... )
350
+
351
+ if resp .Diagnostics .HasError () {
352
+ return
353
+ }
354
+
355
+ typable , diags := coerceObjectTypable (ctx , attrPath , planObjectValuable )
356
+
357
+ resp .Diagnostics .Append (diags ... )
358
+
359
+ if resp .Diagnostics .HasError () {
360
+ return
361
+ }
362
+
312
363
stateObject , diags := setElemObject (ctx , attrPath , stateSet , idx , fwschemadata .DataDescriptionState )
313
364
314
365
resp .Diagnostics .Append (diags ... )
@@ -335,7 +386,26 @@ func AttributeModifyPlan(ctx context.Context, a fwschema.Attribute, req ModifyAt
335
386
336
387
NestedAttributeObjectPlanModify (ctx , nestedAttributeObject , objectReq , objectResp )
337
388
338
- planElements [idx ] = objectResp .AttributePlan
389
+ respValue , diags := coerceObjectValue (ctx , attrPath , objectResp .AttributePlan )
390
+
391
+ resp .Diagnostics .Append (diags ... )
392
+
393
+ if resp .Diagnostics .HasError () {
394
+ return
395
+ }
396
+
397
+ // A custom value type must be returned in the final response to prevent
398
+ // later correctness errors.
399
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/821
400
+ respValuable , diags := typable .ValueFromObject (ctx , respValue )
401
+
402
+ resp .Diagnostics .Append (diags ... )
403
+
404
+ if resp .Diagnostics .HasError () {
405
+ return
406
+ }
407
+
408
+ planElements [idx ] = respValuable
339
409
resp .Diagnostics .Append (objectResp .Diagnostics ... )
340
410
resp .Private = objectResp .Private
341
411
resp .RequiresReplace .Append (objectResp .RequiresReplace ... )
@@ -425,6 +495,22 @@ func AttributeModifyPlan(ctx context.Context, a fwschema.Attribute, req ModifyAt
425
495
return
426
496
}
427
497
498
+ planObjectValuable , diags := coerceObjectValuable (ctx , attrPath , planElem )
499
+
500
+ resp .Diagnostics .Append (diags ... )
501
+
502
+ if resp .Diagnostics .HasError () {
503
+ return
504
+ }
505
+
506
+ typable , diags := coerceObjectTypable (ctx , attrPath , planObjectValuable )
507
+
508
+ resp .Diagnostics .Append (diags ... )
509
+
510
+ if resp .Diagnostics .HasError () {
511
+ return
512
+ }
513
+
428
514
stateObject , diags := mapElemObject (ctx , attrPath , stateMap , key , fwschemadata .DataDescriptionState )
429
515
430
516
resp .Diagnostics .Append (diags ... )
@@ -451,7 +537,26 @@ func AttributeModifyPlan(ctx context.Context, a fwschema.Attribute, req ModifyAt
451
537
452
538
NestedAttributeObjectPlanModify (ctx , nestedAttributeObject , objectReq , objectResp )
453
539
454
- planElements [key ] = objectResp .AttributePlan
540
+ respValue , diags := coerceObjectValue (ctx , attrPath , objectResp .AttributePlan )
541
+
542
+ resp .Diagnostics .Append (diags ... )
543
+
544
+ if resp .Diagnostics .HasError () {
545
+ return
546
+ }
547
+
548
+ // A custom value type must be returned in the final response to prevent
549
+ // later correctness errors.
550
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/821
551
+ respValuable , diags := typable .ValueFromObject (ctx , respValue )
552
+
553
+ resp .Diagnostics .Append (diags ... )
554
+
555
+ if resp .Diagnostics .HasError () {
556
+ return
557
+ }
558
+
559
+ planElements [key ] = respValuable
455
560
resp .Diagnostics .Append (objectResp .Diagnostics ... )
456
561
resp .Private = objectResp .Private
457
562
resp .RequiresReplace .Append (objectResp .RequiresReplace ... )
0 commit comments