{"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/c9def3e214014c1188faabfc4a5bde5095139765/internal/cloud/backend_plan.go#L340-L376","documentation":"Raised by AssertImportCompatible when TFC_AGENT_VERSION is set but cannot be parsed by version.NewVersion (e.g. non-semver, blank, or garbage). The backend cannot determine whether the agent supports import blocks.","triggerScenarios":"import blocks + remote run + agent env var present but malformed so that version.NewVersion(agentEnv) returns an error.","commonSituations":"Agent image sets TFC_AGENT_VERSION to a non-semver value (\"latest\", \"v1\", a git SHA, \"1.10.0-dev+build\"); manual env override with a typo; a CI runner that injects a wrong value.","solutions":["Set TFC_AGENT_VERSION to a valid semantic version string (e.g. 1.10.0).","Remove import blocks from the config and use 'terraform import'.","Rebuild the agent image with a correct version label and report the offending string to the Terraform team."],"exampleFix":"# before\nENV TFC_AGENT_VERSION=latest\n# after\nENV TFC_AGENT_VERSION=1.10.0","handlingStrategy":"validation","validationCode":"v, ok := os.LookupEnv(\"TFC_AGENT_VERSION\")\nif ok {\n    if _, err := version.NewVersion(v); err != nil {\n        return fmt.Errorf(\"TFC_AGENT_VERSION=%q is not a valid semver\", v)\n    }\n}","typeGuard":"func isParsableAgentVersion(v string) bool {\n    _, err := version.NewVersion(v)\n    return err == nil\n}","tryCatchPattern":null,"preventionTips":["Set TFC_AGENT_VERSION to a strict semver (x.y.z).","Validate the env var in the agent container's entrypoint.","Avoid tagging agent images as 'latest'."],"tags":["terraform","import-blocks","hcp-agent","semver","cloud-backend"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}