hashicorp/terraform · error

Error parsing remote API version. To proceed, please remove

Error message

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

What it means

Raised by Cloud.AssertImportCompatible when the config contains import blocks and the process is running inside TFC (TFC_RUN_ID set), but the remote API version string returned by b.client.RemoteAPIVersion() cannot be parsed by hashicorp/go-version's NewVersion. It aborts configuration-driven import because the backend cannot confirm the API supports it.

Source

Thrown at internal/cloud/backend_plan.go:344

	// run, but the user still needs to see why, so this always renders.
	if err := b.renderTFPolicyEvaluations(stopCtx, r,
		tfe.TFPolicyEvaluationStageTypeInit, tfe.TFPolicyEvaluationStageTypePlan); err != nil {
		return r, err
	}

	return r, nil
}

// AssertImportCompatible errors if the user is attempting to use configuration-
// driven import and the version of the agent or API is too low to support it.
func (b *Cloud) AssertImportCompatible(config *configs.Config) error {
	// Check TFC_RUN_ID is populated, indicating we are running in a remote TFC
	// execution environment.
	if len(config.Module.Import) > 0 && os.Getenv("TFC_RUN_ID") != "" {
		// First, check the remote API version is high enough.
		currentAPIVersion, err := version.NewVersion(b.client.RemoteAPIVersion())
		if err != nil {
			return 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)
		}
		desiredAPIVersion, _ := version.NewVersion("2.6")
		if currentAPIVersion.LessThan(desiredAPIVersion) {
			return 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.")
		}

		// Second, check the agent version is high enough.
		agentEnv, isSet := os.LookupEnv("TFC_AGENT_VERSION")
		if !isSet {
			return 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.")
		}
		currentAgentVersion, err := version.NewVersion(agentEnv)
		if err != nil {
			return 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)
		}
		desiredAgentVersion, _ := version.NewVersion("1.10")
		if currentAgentVersion.LessThan(desiredAgentVersion) {
			return 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)

View on GitHub (pinned to c9def3e214)

Solutions

  1. Temporarily remove the import {} blocks from the configuration to unblock the run.
  2. Check the TFE/HCP Terraform backend health and the API endpoint version it advertises (network proxy or malformed gateway response).
  3. Upgrade the Terraform Enterprise installation / agent to a version known to return a valid semver API version.
  4. Report the offending version string (the %s) to the Terraform team as the message instructs.

Example fix

// before
import {
  to = aws_instance.example
  id = "i-123456"
}
// after: comment out / remove until backend reports a valid API version
// import {
//   to = aws_instance.example
//   id = "i-123456"
// }
Defensive patterns

Strategy: validation

Validate before calling

// Pre-flight: only attempt import-compatible runs when the API version parses.
if v, err := version.NewVersion(b.client.RemoteAPIVersion()); err != nil {
    return fmt.Errorf("cannot verify import support: unparseable API version %q; remove import blocks", b.client.RemoteAPIVersion())
}

Type guard

func isValidSemver(s string) bool {
    _, err := version.NewVersion(s)
    return err == nil
}

Try / catch

if err := b.AssertImportCompatible(cfg); err != nil && strings.Contains(err.Error(), "Error parsing remote API version") {
    // strip import blocks and retry, or surface guidance to upgrade the backend
}

Prevention

When it happens

Trigger: Called after config load in a remote run environment when len(config.Module.Import) > 0 and os.Getenv("TFC_RUN_ID") != ""; version.NewVersion(b.client.RemoteAPIVersion()) returns a non-nil error because the string is empty, malformed, or unexpectedly formatted.

Common situations: Terraform Enterprise/HCP Terraform backend returning an unusual/blank API version string (custom TFE install, proxy mangling responses, or an API version that does not conform to semver). Import blocks present in config while running on such a backend.

Related errors


AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07). Data as JSON: /api/errors/43c198ca56204cb2. Report an issue: GitHub.