{"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":"exception","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/c9def3e214014c1188faabfc4a5bde5095139765/internal/cloud/backend_plan.go#L326-L362","documentation":"Raised by Cloud.AssertImportCompatible when the config contains import blocks and the process is running inside TFC (TFC_RUN_ID set), but the remote API version string returned by b.client.RemoteAPIVersion() cannot be parsed by hashicorp/go-version's NewVersion. It aborts configuration-driven import because the backend cannot confirm the API supports it.","triggerScenarios":"Called after config load in a remote run environment when len(config.Module.Import) > 0 and os.Getenv(\"TFC_RUN_ID\") != \"\"; version.NewVersion(b.client.RemoteAPIVersion()) returns a non-nil error because the string is empty, malformed, or unexpectedly formatted.","commonSituations":"Terraform Enterprise/HCP Terraform backend returning an unusual/blank API version string (custom TFE install, proxy mangling responses, or an API version that does not conform to semver). Import blocks present in config while running on such a backend.","solutions":["Temporarily remove the import {} blocks from the configuration to unblock the run.","Check the TFE/HCP Terraform backend health and the API endpoint version it advertises (network proxy or malformed gateway response).","Upgrade the Terraform Enterprise installation / agent to a version known to return a valid semver API version.","Report the offending version string (the %s) to the Terraform team as the message instructs."],"exampleFix":"// before\nimport {\n  to = aws_instance.example\n  id = \"i-123456\"\n}\n// after: comment out / remove until backend reports a valid API version\n// import {\n//   to = aws_instance.example\n//   id = \"i-123456\"\n// }","handlingStrategy":"validation","validationCode":"// Pre-flight: only attempt import-compatible runs when the API version parses.\nif v, err := version.NewVersion(b.client.RemoteAPIVersion()); err != nil {\n    return fmt.Errorf(\"cannot verify import support: unparseable API version %q; remove import blocks\", b.client.RemoteAPIVersion())\n}","typeGuard":"func isValidSemver(s string) bool {\n    _, err := version.NewVersion(s)\n    return err == nil\n}","tryCatchPattern":"if err := b.AssertImportCompatible(cfg); err != nil && strings.Contains(err.Error(), \"Error parsing remote API version\") {\n    // strip import blocks and retry, or surface guidance to upgrade the backend\n}","preventionTips":["Gate import-block configs behind a TFE/HCP version check in CI.","Monitor the API version your backend advertises.","Keep a non-import config variant for older backends."],"tags":["terraform","import-blocks","tfe-version","cloud-backend","semver"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}