hashicorp/terraform · error

Error: unsupported data source %s

Error message

Error: unsupported data source %s

What it means

Returned by `ValidateDataResourceConfig` (provider.go:109) when the request's `TypeName` is anything other than `terraform_remote_state`. The built-in `terraform` provider declares exactly one data source in `GetProviderSchema`, so this guard is commented 'should not happen' and exists purely for robustness against a misbehaving caller of `providers.Interface`.

Source

Thrown at internal/builtin/providers/terraform/provider.go:109

	}
}

// ValidateProviderConfig is used to validate the configuration values.
func (p *Provider) ValidateProviderConfig(req providers.ValidateProviderConfigRequest) providers.ValidateProviderConfigResponse {
	// At this moment there is nothing to configure for the terraform provider,
	// so we will happily return without taking any action
	var res providers.ValidateProviderConfigResponse
	res.PreparedConfig = req.Config
	return res
}

// ValidateDataResourceConfig is used to validate the data source configuration values.
func (p *Provider) ValidateDataResourceConfig(req providers.ValidateDataResourceConfigRequest) providers.ValidateDataResourceConfigResponse {
	var res providers.ValidateDataResourceConfigResponse

	// This should not happen
	if req.TypeName != "terraform_remote_state" {
		res.Diagnostics = res.Diagnostics.Append(fmt.Errorf("Error: unsupported data source %s", req.TypeName))
		return res
	}

	diags := dataSourceRemoteStateValidate(req.Config)
	res.Diagnostics = diags

	return res
}

func (p *Provider) ValidateListResourceConfig(req providers.ValidateListResourceConfigRequest) providers.ValidateListResourceConfigResponse {
	var resp providers.ValidateListResourceConfigResponse
	resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("unsupported list resource type %q", req.TypeName))
	return resp
}

// Configure configures and initializes the provider.
func (p *Provider) ConfigureProvider(providers.ConfigureProviderRequest) providers.ConfigureProviderResponse {
	// At this moment there is nothing to configure for the terraform provider,

View on GitHub (pinned to c9def3e214)

Solutions

  1. Consult `GetProviderSchema().DataSources` and only dispatch types present in that map to this provider.
  2. Ensure the data source is spelled exactly `terraform_remote_state` (case-sensitive, underscore-separated).
  3. If you need a different data source, use the provider that actually advertises it rather than the built-in `terraform` provider.
  4. Reproduce with the real Terraform CLI first to confirm the request is genuinely being routed here.

Example fix

// before
data "terraform_other" "x" { ... }

// after
data "terraform_remote_state" "x" { ... }
Defensive patterns

Strategy: validation

Validate before calling

// Only validate data sources this provider actually advertises.
schema := provider.GetProviderSchema()
if _, ok := schema.DataSources[req.TypeName]; !ok {
    // route to a different provider or report a user-facing error;
    // do NOT call ValidateDataResourceConfig for this type.
    return unsupportedDataSource(req.TypeName)
}

Type guard

func providerSupportsDataSource(schema providers.GetProviderSchemaResponse, name string) bool {
    _, ok := schema.DataSources[name]
    return ok
}

Prevention

When it happens

Trigger: A `providers.Interface` caller (Terraform core's resource dispatcher, a custom TFCL runtime, or a test) routes a `ValidateDataResourceConfigRequest` whose `TypeName` is not `terraform_remote_state` to this provider instance.

Common situations: A buggy provider router that does not consult `GetProviderSchema().DataSources`; a unit test stub that hard-codes a wrong type name; an experimental runtime adding new data sources without updating the schema advertisement.

Related errors


AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07). Data as JSON: /api/errors/f518fa46a19c858d. Report an issue: GitHub.