So, since verification of a domain is skipped when this provider sets domains via the API thus skipping the TXT DNS record verification phase - there doesn't seem to be a built in constraint in this system that says an organization can't have a domain already assigned to an existing organization.
The WorkOS constraint on this is via the TXT DNS challenge, since multiple orgs will have different challenges and thus incompatible TXT values for the same DNS zone - but if you're pre verifying the domain and this constraint is no longer in play, what stops you creating multiple organizations in terraform using the same domain.
Given that, the data source for workos_organization, when you try to capture the state via a domain (rather than id) is currently working under the impression the list orgs response will either give an empty array or a single response, because the data source does not return multiple.
This may be a known limitation of the provider, or it's a capability miss that could be dangerous and unpredictable results when using this data source with the domain lookup key.
So, since verification of a domain is skipped when this provider sets domains via the API thus skipping the TXT DNS record verification phase - there doesn't seem to be a built in constraint in this system that says an organization can't have a domain already assigned to an existing organization.
The WorkOS constraint on this is via the TXT DNS challenge, since multiple orgs will have different challenges and thus incompatible TXT values for the same DNS zone - but if you're pre verifying the domain and this constraint is no longer in play, what stops you creating multiple organizations in terraform using the same domain.
Given that, the data source for workos_organization, when you try to capture the state via a domain (rather than id) is currently working under the impression the list orgs response will either give an empty array or a single response, because the data source does not return multiple.
This may be a known limitation of the provider, or it's a capability miss that could be dangerous and unpredictable results when using this data source with the domain lookup key.