{"record":{"id":"b041d590a96aa124","repo":"hashicorp/terraform","slug":"error-reading-hcp-terraform-agent-version-to-proc","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/backend_plan.go","lineNumber":354,"sourceCode":"// 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)\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 {","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/cloud/backend_plan.go#L336-L372","documentation":"Raised by AssertImportCompatible when import blocks are present in a remote run and the TFC_AGENT_VERSION environment variable is not set at all. The backend needs the agent version to verify it supports import (>= 1.10); absence prevents the check.","triggerScenarios":"config has import blocks, TFC_RUN_ID set, API version OK, but os.LookupEnv(\"TFC_AGENT_VERSION\") returns isSet == false.","commonSituations":"Running on a custom or misconfigured HCP Terraform Agent image where the agent startup does not export TFC_AGENT_VERSION; older agent versions that predate the variable; importing blocks into a workspace whose agent pool runs such an image.","solutions":["Remove import blocks from the config and import imperatively.","Update/recreate the HCP Terraform Agent so that TFC_AGENT_VERSION is exported (use an agent image >= 1.10 that sets the variable).","Run the operation with local execution instead of the agent."],"exampleFix":"# before: agent image missing the variable (env shows nothing)\n# after: ensure the agent Dockerfile / entrypoint exports it\nENV TFC_AGENT_VERSION=1.10.0","handlingStrategy":"validation","validationCode":"// Detect missing agent version before running.\nif _, ok := os.LookupEnv(\"TFC_AGENT_VERSION\"); !ok && hasImportBlocks(cfg) {\n    return fmt.Errorf(\"TFC_AGENT_VERSION unset; cannot verify agent import support\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Bake TFC_AGENT_VERSION into the agent image entrypoint.","Use a supported (>= 1.10) agent image.","Test import-block configs in a staging workspace first."],"tags":["terraform","import-blocks","hcp-agent","cloud-backend","env-var"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}