hashicorp/terraform · error

error in marshaling deferred action invocations: %s

Error message

error in marshaling deferred action invocations: %s

What it means

Top-level wrapper: serializing deferred action invocations (p.DeferredActionInvocations) via MarshalDeferredActionInvocations failed. Each deferred invocation is marshaled with MarshalActionInvocation, so the inner error is one of 600-603.

Source

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

	// 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 {
		output.DeferredActionInvocations, err = MarshalDeferredActionInvocations(p.DeferredActionInvocations, schemas)
		if err != nil {
			return nil, fmt.Errorf("error in marshaling deferred action invocations: %s", err)
		}
	}

	// output.OutputChanges
	if output.OutputChanges, err = MarshalOutputChanges(p.Changes); err != nil {
		return nil, fmt.Errorf("error in marshaling output changes: %s", err)
	}

	// output.Checks
	if p.Checks != nil && p.Checks.ConfigResults.Len() > 0 {
		output.Checks = jsonchecks.MarshalCheckStates(p.Checks)
	}

	// output.PriorState
	if sf != nil && !sf.State.Empty() {
		output.PriorState, err = jsonstate.Marshal(sf, schemas)
		if err != nil {
			return nil, fmt.Errorf("error marshaling prior state: %s", err)

View on GitHub (pinned to c9def3e214)

Solutions

  1. Inspect the inner error (600-603) for the specific action and cause.
  2. Remove ephemeral/unsupported references from the action config.
  3. Regenerate the plan with consistent Terraform/provider versions.
Defensive patterns

Strategy: try-catch

Try / catch

deferred, err := jsonplan.MarshalDeferredActionInvocations(plan.DeferredActionInvocations, schemas)
if err != nil {
    // inner error is one of 600-603; unwrap to identify the action
    return fmt.Errorf("marshal deferred actions: %w", err)
}

Prevention

When it happens

Trigger: p.DeferredActionInvocations != nil and one deferred action invocation fails to decode or has unsupported marks/trigger type. Reached when planning produces deferred actions.

Common situations: Deferred actions whose config contains ephemeral values (602); schema mismatch for the action (600); version skew introducing new marks (603) or trigger types (601).

Related errors


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