Skip to content

v1.15.1 causing computed attrs to throw "produced an unexpected new value" on child attributes of an attribute that was null on create and filled in on update #1211

@mawasile

Description

@mawasile

Module version

1.15.1

Relevant provider source code

https://github.com/microsoft/terraform-provider-power-platform/blob/d33ddd7dead09a245466a7bb456d0c4ee7cd0fcb/internal/services/environment/resource_environment.go#L653
https://github.com/microsoft/terraform-provider-power-platform/blob/d33ddd7dead09a245466a7bb456d0c4ee7cd0fcb/internal/services/environment/models.go#L240

	attrTypesDataverseObject := map[string]attr.Type{
		"url":                          types.StringType,
		"domain":                       types.StringType,
		"organization_id":              types.StringType,
		"security_group_id":            types.StringType,
		"language_code":                types.Int64Type,
		"version":                      types.StringType,
		"linked_app_type":              types.StringType,
		"linked_app_id":                types.StringType,
		"linked_app_url":               types.StringType,
		"currency_code":                types.StringType,
		"templates":                    types.ListType{ElemType: types.StringType},
		"template_metadata":            types.StringType,
		"administration_mode_enabled":  types.BoolType,
		"background_operation_enabled": types.BoolType,
		"unique_name":                  types.StringType,
	}

	attrValuesProductProperties := map[string]attr.Value{}
	model.Dataverse = types.ObjectNull(attrTypesDataverseObject)

Terraform Configuration Files

please look at unit test
https://github.com/microsoft/terraform-provider-power-platform/blob/d33ddd7dead09a245466a7bb456d0c4ee7cd0fcb/internal/services/environment/resource_environment_test.go#L1920

or run it using from our repository using

make unittest TEST=EnvironmentsResource_Validate_Create_Environment_And_Dataverse

Debug Output

2025-08-25T10:48:46.928Z [ERROR] sdk.helper_resource: Unexpected error: test_step_number=2 test_name=TestUnitEnvironmentsResource_Validate_Create_Environment_And_Dataverse test_terraform_path=/home/runtimeuser/tfenv/bin/terraform test_working_directory=/tmp/plugintest3209803560
error=
| Error running apply: exit status 1
|
| Error: Provider produced inconsistent result after apply
|
| When applying changes to powerplatform_environment.development, provider
| "provider["registry.terraform.io/hashicorp/powerplatform"]" produced an
| unexpected new value: .dataverse.linked_app_id: was null, but now
| cty.StringVal("").
|
| This is a bug in the provider, which should be reported in the provider's own
| issue tracker.
|
| Error: Provider produced inconsistent result after apply
|
| When applying changes to powerplatform_environment.development, provider
| "provider["registry.terraform.io/hashicorp/powerplatform"]" produced an
| unexpected new value: .dataverse.organization_id: was null, but now
| cty.StringVal("orgid").
|
| This is a bug in the provider, which should be reported in the provider's own
| issue tracker.
|
| Error: Provider produced inconsistent result after apply
|
| When applying changes to powerplatform_environment.development, provider
| "provider["registry.terraform.io/hashicorp/powerplatform"]" produced an
| unexpected new value: .dataverse.version: was null, but now
| cty.StringVal("9.2.23092.00206").
|
| This is a bug in the provider, which should be reported in the provider's own
| issue tracker.
|
| Error: Provider produced inconsistent result after apply
|
| When applying changes to powerplatform_environment.development, provider
| "provider["registry.terraform.io/hashicorp/powerplatform"]" produced an
| unexpected new value: .dataverse.unique_name: was null, but now
| cty.StringVal("00000000-0000-0000-0000-000000000001").
|
| This is a bug in the provider, which should be reported in the provider's own
| issue tracker.
|
| Error: Provider produced inconsistent result after apply
|
| When applying changes to powerplatform_environment.development, provider
| "provider["registry.terraform.io/hashicorp/powerplatform"]" produced an
| unexpected new value: .dataverse.linked_app_url: was null, but now
| cty.StringVal("").
|
| This is a bug in the provider, which should be reported in the provider's own
| issue tracker.
|
| Error: Provider produced inconsistent result after apply
|
| When applying changes to powerplatform_environment.development, provider
| "provider["registry.terraform.io/hashicorp/powerplatform"]" produced an
| unexpected new value: .dataverse.linked_app_type: was null, but now
| cty.StringVal("").
|
| This is a bug in the provider, which should be reported in the provider's own
| issue tracker.

--- FAIL: TestUnitEnvironmentsResource_Validate_Create_Environment_And_Dataverse (0.79s)
/workspaces/terraform-provider-power-platform/internal/services/environment/resource_environment_test.go:1988: Step 2/2 error: Error running apply: exit status 1

    Error: Provider produced inconsistent result after apply
    
    When applying changes to powerplatform_environment.development, provider
    "provider[\"registry.terraform.io/hashicorp/powerplatform\"]" produced an
    unexpected new value: .dataverse.linked_app_id: was null, but now
    cty.StringVal("").
    
    This is a bug in the provider, which should be reported in the provider's own
    issue tracker.
    
    Error: Provider produced inconsistent result after apply
    
    When applying changes to powerplatform_environment.development, provider
    "provider[\"registry.terraform.io/hashicorp/powerplatform\"]" produced an
    unexpected new value: .dataverse.organization_id: was null, but now
    cty.StringVal("orgid").
    
    This is a bug in the provider, which should be reported in the provider's own
    issue tracker.
    
    Error: Provider produced inconsistent result after apply
    
    When applying changes to powerplatform_environment.development, provider
    "provider[\"registry.terraform.io/hashicorp/powerplatform\"]" produced an
    unexpected new value: .dataverse.version: was null, but now
    cty.StringVal("9.2.23092.00206").
    
    This is a bug in the provider, which should be reported in the provider's own
    issue tracker.
    
    Error: Provider produced inconsistent result after apply
    
    When applying changes to powerplatform_environment.development, provider
    "provider[\"registry.terraform.io/hashicorp/powerplatform\"]" produced an
    unexpected new value: .dataverse.unique_name: was null, but now
    cty.StringVal("00000000-0000-0000-0000-000000000001").
    
    This is a bug in the provider, which should be reported in the provider's own
    issue tracker.
    
    Error: Provider produced inconsistent result after apply
    
    When applying changes to powerplatform_environment.development, provider
    "provider[\"registry.terraform.io/hashicorp/powerplatform\"]" produced an
    unexpected new value: .dataverse.linked_app_url: was null, but now
    cty.StringVal("").
    
    This is a bug in the provider, which should be reported in the provider's own
    issue tracker.
    
    Error: Provider produced inconsistent result after apply
    
    When applying changes to powerplatform_environment.development, provider
    "provider[\"registry.terraform.io/hashicorp/powerplatform\"]" produced an
    unexpected new value: .dataverse.linked_app_type: was null, but now
    cty.StringVal("").
    
    This is a bug in the provider, which should be reported in the provider's own
    issue tracker.

FAIL
FAIL github.com/microsoft/terraform-provider-power-platform/internal/services/environment 0.797s
FAIL

Expected Behavior

We firstly create

resource "powerplatform_environment" "development" {
	display_name                              = "displayname"
	location                                  = "europe"
	environment_type                          = "Sandbox"
}

to later update the resource with

resource "powerplatform_environment" "development" {
	display_name                              = "displayname"
	location                                  = "europe"
	environment_type                          = "Sandbox"
	dataverse = {
		language_code                             = "1033"
		currency_code                             = "PLN"
		domain                                    = "00000000-0000-0000-0000-000000000001"
		security_group_id                         = "00000000-0000-0000-0000-000000000000"
	}
}

The dataverse value is null and then filled in with attributes for following update operation. In v1.15.1 the computer attributes under dataverse when update with value throw and unexpected value error.

Actual Behavior

The framework should work like in v1.15.0 and lower. Please confirm if I should change the code on my side and this is a breaking change or its a but in the newest release of the framework?

Steps to Reproduce

You can run TestUnitEnvironmentsResource_Validate_Create_Environment_And_Dataverse unit test from our repo and step debug (use dev container from the repo).

make unittest TEST=EnvironmentsResource_Validate_Create_Environment_And_Dataverse

References

looks like #1117 may be the root cause.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions