{"record":{"id":"43c198ca56204cb2","repo":"hashicorp/terraform","slug":"error-parsing-remote-api-version-to-proceed-plea","errorCode":null,"errorMessage":"Error parsing remote API version. To proceed, please remove any import blocks from your config. Please report the following error to the Terraform team: %s","messagePattern":"Error parsing remote API version\\. To proceed, please remove any import blocks from your config\\. Please report the following error to the Terraform team: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/backend_plan.go","lineNumber":344,"sourceCode":"\t// run, but the user still needs to see why, so this always renders.\n\tif err := b.renderTFPolicyEvaluations(stopCtx, r,\n\t\ttfe.TFPolicyEvaluationStageTypeInit, tfe.TFPolicyEvaluationStageTypePlan); err != nil {\n\t\treturn r, err\n\t}\n\n\treturn r, nil\n}\n\n// AssertImportCompatible errors if the user is attempting to use configuration-\n// driven import and the version of the agent or API is too low to support it.\nfunc (b *Cloud) AssertImportCompatible(config *configs.Config) error {\n\t// Check TFC_RUN_ID is populated, indicating we are running in a remote TFC\n\t// execution environment.\n\tif len(config.Module.Import) > 0 && os.Getenv(\"TFC_RUN_ID\") != \"\" {\n\t\t// First, check the remote API version is high enough.\n\t\tcurrentAPIVersion, err := version.NewVersion(b.client.RemoteAPIVersion())\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Error parsing remote API version. To proceed, please remove any import blocks from your config. Please report the following error to the Terraform team: %s\", err)\n\t\t}\n\t\tdesiredAPIVersion, _ := version.NewVersion(\"2.6\")\n\t\tif currentAPIVersion.LessThan(desiredAPIVersion) {\n\t\t\treturn fmt.Errorf(\"Import blocks are not supported in this version of Terraform Enterprise. Please remove any import blocks from your config or upgrade Terraform Enterprise.\")\n\t\t}\n\n\t\t// Second, check the agent version is high enough.\n\t\tagentEnv, isSet := os.LookupEnv(\"TFC_AGENT_VERSION\")\n\t\tif !isSet {\n\t\t\treturn fmt.Errorf(\"Error reading HCP Terraform Agent version. To proceed, please remove any import blocks from your config. Please report the following error to the Terraform team: TFC_AGENT_VERSION not present.\")\n\t\t}\n\t\tcurrentAgentVersion, err := version.NewVersion(agentEnv)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Error parsing HCP Terraform Agent version. To proceed, please remove any import blocks from your config. Please report the following error to the Terraform team: %s\", err)\n\t\t}\n\t\tdesiredAgentVersion, _ := version.NewVersion(\"1.10\")\n\t\tif currentAgentVersion.LessThan(desiredAgentVersion) {\n\t\t\treturn fmt.Errorf(\"Import blocks are not supported in this version of the HCP Terraform Agent. You are using agent version %s, but this feature requires version %s. Please remove any import blocks from your config or upgrade your agent.\", currentAgentVersion, desiredAgentVersion)","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/cloud/backend_plan.go#L326-L362","documentation":"Thrown by Cloud.AssertImportCompatible when version.NewVersion(b.client.RemoteAPIVersion()) returns an error. The backend asks the TFE/HCP API for its version string and tries to parse it; if the string is empty, malformed, or non-semver, parsing fails. This gates configuration-driven import blocks (added in Terraform 1.5+) in remote execution.","triggerScenarios":"Only fires when config.Module.Import has entries AND TFC_RUN_ID is set (i.e. running inside a remote TFC/TFE execution environment). The RemoteAPIVersion() call returns something version.NewVersion cannot parse — an older TFE that doesn't report a version, a custom API gateway stripping the version header, or a malformed response.","commonSituations":"Old self-hosted Terraform Enterprise that predates the API-version endpoint; a reverse proxy/load balancer in front of TFE stripping the version response; import blocks used against a TFE version that lacks the version-reporting capability.","solutions":["Remove import blocks from the configuration to bypass the compatibility check entirely.","Upgrade the Terraform Enterprise installation so it reports a parseable API version (>= 2.6 ideally).","Inspect b.client.RemoteAPIVersion() output (enable TRACE/DEBUG logging) to see the malformed string and fix the proxy/gateway mangling it.","Ensure no middlebox between the agent and TFE strips the version header."],"exampleFix":"// before - config has import blocks but TFE returns no version\nimport {\n  to = aws_instance.example\n  id = \"i-1234567890abcdef0\"\n}\n// after - remove import blocks for this TFE version, or upgrade TFE","handlingStrategy":"validation","validationCode":"// Pre-check the API version string is parseable before relying on it.\nif _, err := version.NewVersion(b.client.RemoteAPIVersion()); err != nil {\n    // log and either skip import blocks or surface a clearer error\n}","typeGuard":"func isParseableVersion(v string) bool {\n    _, err := version.NewVersion(v)\n    return err == nil\n}","tryCatchPattern":"v, err := version.NewVersion(b.client.RemoteAPIVersion())\nif err != nil {\n    return fmt.Errorf(\"unparseable remote API version %q: %w\", b.client.RemoteAPIVersion(), err)\n}","preventionTips":["Upgrade TFE so it reports a valid semver API version.","Ensure no proxy strips the version response from the TFE API.","Avoid import blocks against TFE versions known to omit the version endpoint."],"tags":["terraform","import","tfe","api-version","remote-execution","version-check"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}