{"record":{"id":"f518fa46a19c858d","repo":"hashicorp/terraform","slug":"error-unsupported-data-source-s","errorCode":null,"errorMessage":"Error: unsupported data source %s","messagePattern":"Error: unsupported data source (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/builtin/providers/terraform/provider.go","lineNumber":109,"sourceCode":"\t}\n}\n\n// ValidateProviderConfig is used to validate the configuration values.\nfunc (p *Provider) ValidateProviderConfig(req providers.ValidateProviderConfigRequest) providers.ValidateProviderConfigResponse {\n\t// At this moment there is nothing to configure for the terraform provider,\n\t// so we will happily return without taking any action\n\tvar res providers.ValidateProviderConfigResponse\n\tres.PreparedConfig = req.Config\n\treturn res\n}\n\n// ValidateDataResourceConfig is used to validate the data source configuration values.\nfunc (p *Provider) ValidateDataResourceConfig(req providers.ValidateDataResourceConfigRequest) providers.ValidateDataResourceConfigResponse {\n\tvar res providers.ValidateDataResourceConfigResponse\n\n\t// This should not happen\n\tif req.TypeName != \"terraform_remote_state\" {\n\t\tres.Diagnostics = res.Diagnostics.Append(fmt.Errorf(\"Error: unsupported data source %s\", req.TypeName))\n\t\treturn res\n\t}\n\n\tdiags := dataSourceRemoteStateValidate(req.Config)\n\tres.Diagnostics = diags\n\n\treturn res\n}\n\nfunc (p *Provider) ValidateListResourceConfig(req providers.ValidateListResourceConfigRequest) providers.ValidateListResourceConfigResponse {\n\tvar resp providers.ValidateListResourceConfigResponse\n\tresp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf(\"unsupported list resource type %q\", req.TypeName))\n\treturn resp\n}\n\n// Configure configures and initializes the provider.\nfunc (p *Provider) ConfigureProvider(providers.ConfigureProviderRequest) providers.ConfigureProviderResponse {\n\t// At this moment there is nothing to configure for the terraform provider,","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/builtin/providers/terraform/provider.go#L91-L127","documentation":"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`.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Consult `GetProviderSchema().DataSources` and only dispatch types present in that map to this provider.","Ensure the data source is spelled exactly `terraform_remote_state` (case-sensitive, underscore-separated).","If you need a different data source, use the provider that actually advertises it rather than the built-in `terraform` provider.","Reproduce with the real Terraform CLI first to confirm the request is genuinely being routed here."],"exampleFix":"// before\ndata \"terraform_other\" \"x\" { ... }\n\n// after\ndata \"terraform_remote_state\" \"x\" { ... }","handlingStrategy":"validation","validationCode":"// Only validate data sources this provider actually advertises.\nschema := provider.GetProviderSchema()\nif _, ok := schema.DataSources[req.TypeName]; !ok {\n    // route to a different provider or report a user-facing error;\n    // do NOT call ValidateDataResourceConfig for this type.\n    return unsupportedDataSource(req.TypeName)\n}","typeGuard":"func providerSupportsDataSource(schema providers.GetProviderSchemaResponse, name string) bool {\n    _, ok := schema.DataSources[name]\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Cache GetProviderSchema per provider and consult it on every dispatch.","Spell the data source exactly `terraform_remote_state`.","In tests, derive expected type names from the schema rather than hard-coding strings."],"tags":["terraform","builtin-provider","data-source","dispatch","defensive","provider-interface"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}