hashicorp/terraform · error

error marshaling relevant attributes for external changes

Error message

error marshaling relevant attributes for external changes: %s

What it means

Top-level propagation error from Marshal: marshalRelevantAttrs failed. This step computes the set of attributes relevant to external changes for the rendered plan. Failure typically comes from path or schema handling during relevance computation.

Solutions

  1. Read the wrapped error to identify the attribute path or resource at fault.
  2. Regenerate the plan with the current Terraform and providers.
  3. Ensure all providers referenced by the plan are initialized.
  4. Upgrade Terraform if the relevant-attributes feature is newer than this binary supports.
Defensive patterns

Strategy: try-catch

Try / catch

if err := output.marshalRelevantAttrs(p); err != nil {
    return nil, fmt.Errorf("relevant-attrs render failed: %%w", err)
}

Prevention

When it happens

Trigger: Plan contains relevant-attribute paths that reference resource types whose schema is missing at render time, or path steps that fail to match against the current schema.

Common situations: Cross-version rendering where relevant-attribute paths were computed by a newer Terraform; provider schemas not fully loaded.

Related errors


AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11). Data as JSON: /api/errors/fae6b5bbc1df4cf7. Report an issue: GitHub.

Appendix: source

Thrown at internal/command/jsonplan/plan.go:298

		// we skip them here.
		var driftedResources []*plans.ResourceInstanceChangeSrc
		if p.UIMode == plans.RefreshOnlyMode {
			driftedResources = p.DriftedResources
		} else {
			for _, dr := range p.DriftedResources {
				if dr.Action != plans.NoOp {
					driftedResources = append(driftedResources, dr)
				}
			}
		}
		output.ResourceDrift, err = MarshalResourceChanges(driftedResources, schemas)
		if err != nil {
			return nil, fmt.Errorf("error in marshaling resource drift: %s", err)
		}
	}

	if err := output.marshalRelevantAttrs(p); err != nil {
		return nil, fmt.Errorf("error marshaling relevant attributes for external changes: %s", err)
	}

	// output.ResourceChanges
	if p.Changes != nil {
		output.ResourceChanges, err = MarshalResourceChanges(p.Changes.Resources, schemas)
		if err != nil {
			return nil, fmt.Errorf("error in marshaling resource changes: %s", err)
		}
	}

	if p.DeferredResources != nil {
		output.DeferredChanges, err = MarshalDeferredResourceChanges(p.DeferredResources, schemas)
		if err != nil {
			return nil, fmt.Errorf("error in marshaling deferred resource changes: %s", err)
		}
	}

	if p.DeferredActionInvocations != nil {

View on GitHub (pinned to d32a084675)