{"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":"validation","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/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/cloud/backend_plan.go#L336-L372","documentation":"Thrown by Cloud.AssertImportCompatible when os.LookupEnv(\"TFC_AGENT_VERSION\") reports the variable is not set. After confirming the API version supports import, the backend checks the HCP Terraform Agent version (>= 1.10 required); if the agent environment variable is absent, it cannot verify agent compatibility and refuses to proceed with import blocks.","triggerScenarios":"Fires only when: import blocks are present, TFC_RUN_ID is set (remote execution), and the API version already passed. The TFC_AGENT_VERSION env var is expected to be injected by the HCP Terraform Agent runtime; its absence means the agent is older than the version that sets it, or a custom/agentless execution environment.","commonSituations":"Running an HCP Terraform Agent older than 1.10 that does not export TFC_AGENT_VERSION; a custom runner/container that mimics the TFC execution env but omits the variable; agent image misconfigured to drop environment variables.","solutions":["Upgrade the HCP Terraform Agent to version 1.10 or later, which exports TFC_AGENT_VERSION.","Remove import blocks from the config so the agent-version check is skipped entirely.","If using a custom agent image, ensure it sets TFC_AGENT_VERSION to a valid semver >= 1.10.","Verify the agent pod/container env is not being stripped by an orchestrator policy."],"exampleFix":"// before - agent < 1.10 omits TFC_AGENT_VERSION, import blocks fail\nimport {\n  to = aws_instance.example\n  id = \"i-1234567890abcdef0\"\n}\n// after - upgrade agent to >= 1.10, or remove the import block","handlingStrategy":"validation","validationCode":"// Verify the agent env var is set before remote execution with import blocks.\nif _, ok := os.LookupEnv(\"TFC_AGENT_VERSION\"); !ok {\n    // refuse import blocks or surface early\n}","typeGuard":"func agentVersionKnown() bool {\n    _, ok := os.LookupEnv(\"TFC_AGENT_VERSION\")\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Deploy HCP Terraform Agent >= 1.10, which exports TFC_AGENT_VERSION.","In custom agent images, always set TFC_AGENT_VERSION to a valid semver.","Avoid import blocks until the agent pool is upgraded."],"tags":["terraform","import","hcp-terraform-agent","env-var","version-check","remote-execution"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}