Refreshing state error

Hi everyone,
I am sending the code below through main.tf file, which should just send a read request to service, but for some reason it is first “refreshing state” for the read request to packages and is giving an error

data "logiprovider_service" "new" {
  id = 2
}
output "new" {
  value = data.logiprovider_service.new
}

*Note: I am using a custom provider.

The error which I am getting is below:

We can see in the error message that first it is sending the read request through data.logiprovider_service.new, but then it is “refreshing state” of logiprovider_package.example which I am not even calling.

Also to note the read is successful, but it still shows error due to “refreshing state”

Thanks.

Hi @aradhu,

It’s hard to tell what is going on here from the limited example. The logiprovider_package.example will be read during a plan if it exists in your config or state file. If the resource is not expected to exist, then the provider should indicate that rather than returning an error.

The output shown also looks incomplete, so I would also verify that you are using a current Terraform release which may show more diagnostic information.

Thanks, as you said it was in state file and was causing the issue. It resolved after clearing the state file.