Read condition over a state parameter not initialized at import

Hello,

I’m working on a provider to manage PowerDNS through its API. We manage zone and records ressources, but in the API records are a subset of a zone.

We provide a nameserver parameter in the zone resource because the API let us defined them on zone creation. This parameter is optional, so creating the resource do not create the records at all.

The problem is that I need to check in the read function if the nameservers are defined and not equal to 0, otherwise the state is updated with the existing records but they must not be managed by the resource.

Currently i wrote this check:

if len(d.Get(“nameservers”).(*schema.Set).List()) > 0

But the checks are failing because the state is blank :

testing.go:569: Step 1 error: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.

    (map[string]string) {
    }
    
    
    (map[string]string) (len=3) {
     (string) (len=13) "nameservers.#": (string) (len=1) "2",
     (string) (len=21) "nameservers.186496283": (string) (len=13) "ns2.sysa.abc.",
     (string) (len=22) "nameservers.2088986603": (string) (len=13) "ns1.sysa.abc."
    }

It looks like d.Get(“var”) in the Read function get it from the state. How do I read the input parameter instead ?