{"record":{"id":"f776e010dbec9faf","repo":"opentofu/opentofu","slug":"error-parsing-tfc-agent-version-to-proceed-pleas","errorCode":null,"errorMessage":"Error parsing TFC agent version. To proceed, please remove any import blocks from your config. Please report the following error to the OpenTofu team: %w","messagePattern":"Error parsing TFC agent version\\. To proceed, please remove any import blocks from your config\\. Please report the following error to the OpenTofu team: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/backend_plan.go","lineNumber":415,"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 OpenTofu team: %w\", 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 the cloud backend. Please remove any import blocks from your config or upgrade the cloud backend.\")\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 TFC agent version. To proceed, please remove any import blocks from your config. Please report the following error to the OpenTofu 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 TFC agent version. To proceed, please remove any import blocks from your config. Please report the following error to the OpenTofu team: %w\", 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 cloud backend 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 *backend.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.View != nil {","sourceCodeStart":397,"sourceCodeEnd":433,"githubUrl":"https://github.com/opentofu/opentofu/blob/3561785c48c1ce615e7c50261bd351f26053efa2/internal/cloud/backend_plan.go#L397-L433","documentation":"Version gate in Cloud.assertImportCompatible: import blocks are used in a remote run, TFC_AGENT_VERSION is set, but its value cannot be parsed as a semantic version by version.NewVersion. The wrapped err from the parser is included so you can see the offending input format.","triggerScenarios":"Import blocks + TFC_RUN_ID set + TFC_AGENT_VERSION present but malformed — e.g., 'unknown', 'latest', '1.10.x', a git sha, or a value with stray whitespace/quotes injected by a custom harness or CI templating.","commonSituations":"Custom agent wrappers exporting a placeholder like TFC_AGENT_VERSION=$(git rev-parse HEAD); CI systems quoting or interpolating the variable incorrectly; hand-crafted containers copying TFC env conventions imperfectly.","solutions":["Set TFC_AGENT_VERSION to a valid semantic version string that matches the deployed agent, e.g. 1.10.0","Remove the `import` blocks and use `tofu import` CLI instead","Use the official TFC/TFE agent image, which exports a well-formed version","Check for shell quoting/templating bugs in whatever injects the variable (trailing newline, quotes)"],"exampleFix":"# before (custom harness)\nexport TFC_AGENT_VERSION=\"latest\"\n\n# after\nexport TFC_AGENT_VERSION=\"1.10.0\"","handlingStrategy":"validation","validationCode":"if v, ok := os.LookupEnv(\"TFC_AGENT_VERSION\"); ok {\n    if _, err := version.NewVersion(v); err != nil {\n        log.Fatalf(\"TFC_AGENT_VERSION=%q is not a valid semver\", v)\n    }\n}","typeGuard":"func validAgentVersionEnv(v string) bool {\n\t_, err := version.NewVersion(v)\n\treturn err == nil\n}","tryCatchPattern":null,"preventionTips":["Inject TFC_AGENT_VERSION from the agent binary itself (agent --version), never from git shas or 'latest'","Validate env templates in CI with a schema/lint step","Quote and trim variables when templating harness env files"],"tags":["cloud-backend","import-blocks","environment-variables","version-parsing","agent"],"backgroundTag":null,"analyzedSha":"3561785c48c1ce615e7c50261bd351f26053efa2","analyzedAt":"2026-08-15T23:27:16.226Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}