{"record":{"id":"6b7007ceec38a988","repo":"hashicorp/terraform","slug":"error-parsing-hcp-terraform-agent-version-to-proc","errorCode":null,"errorMessage":"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","messagePattern":"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: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/backend_plan.go","lineNumber":358,"sourceCode":"\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)\n\t\t}\n\t}\n\treturn nil\n}\n\n// renderPlanLogs reads the streamed plan JSON logs and calls the JSON Plan renderer (jsonformat.RenderPlan) to\n// render the plan output. The plan output is fetched from the redacted output endpoint.\nfunc (b *Cloud) renderPlanLogs(ctx context.Context, op *backendrun.Operation, run *tfe.Run) error {\n\tlogs, err := b.client.Plans.Logs(ctx, run.Plan.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif b.CLI != nil {","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/cloud/backend_plan.go#L340-L376","documentation":"Thrown by Cloud.AssertImportCompatible when os.LookupEnv confirms TFC_AGENT_VERSION is set but version.NewVersion(agentEnv) fails to parse it. The value must be a valid semver-like string; garbage, empty-after-set, or non-numeric content causes the parse error.","triggerScenarios":"TFC_AGENT_VERSION is present but contains a non-parseable string (e.g. 'latest', 'unknown', a git SHA, an empty string from a broken export, or a version with invalid characters). version.NewVersion requires a recognized semver-ish format.","commonSituations":"Custom agent image that sets TFC_AGENT_VERSION to a build tag or commit hash instead of a release semver; a CI pipeline that writes a non-semver into the env; an agent that exports a pre-release string the parser rejects.","solutions":["Set TFC_AGENT_VERSION to a valid semver string (e.g. '1.10.0') in the agent runtime.","Upgrade to an official HCP Terraform Agent release that exports a correctly formatted version.","Remove import blocks to bypass the check.","Inspect the raw TFC_AGENT_VERSION value in the agent container and correct the export script."],"exampleFix":"// before - non-semver agent version breaks the parse\n// TFC_AGENT_VERSION=latest  (or a git sha)\n// after - use a valid semver\n// TFC_AGENT_VERSION=1.10.0","handlingStrategy":"validation","validationCode":"// Validate the agent version string is parseable semver.\nif v, err := version.NewVersion(os.Getenv(\"TFC_AGENT_VERSION\")); err != nil {\n    return fmt.Errorf(\"TFC_AGENT_VERSION unparseable: %w\", err)\n}","typeGuard":"func agentVersionValid() bool {\n    _, err := version.NewVersion(os.Getenv(\"TFC_AGENT_VERSION\"))\n    return err == nil\n}","tryCatchPattern":null,"preventionTips":["Set TFC_AGENT_VERSION to a release semver (e.g. 1.10.0), never 'latest' or a git SHA.","Use official agent images that format the version correctly.","Add a startup check in custom agent images that fails fast on a bad version env."],"tags":["terraform","import","hcp-terraform-agent","env-var","semver","version-check"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}