hashicorp/terraform · error

error in marshalPlannedValues

Error message

error in marshalPlannedValues: %s

What it means

Top-level propagation error from Marshal: marshalPlannedValues failed while rendering the planned resource and output values. The wrapped error names the sub-component (resource schema, decode, or value marshal) that failed.

Solutions

  1. Read the wrapped error to locate the failing resource or output.
  2. Re-run `terraform init` and `terraform plan` so planned values align with current schemas.
  3. Verify provider versions are consistent between plan creation and rendering.
  4. Check for missing resource type schemas (see error 619).
Defensive patterns

Strategy: try-catch

Try / catch

if err := output.marshalPlannedValues(p.Changes, schemas); err != nil {
    return nil, fmt.Errorf("planned values render failed (likely schema/decode): %%w", err)
}

Prevention

When it happens

Trigger: A planned resource cannot be decoded against the current provider schema (missing/stale schema), or a value cannot be marshaled to JSON due to type/marks issues.

Common situations: Provider schema changed after planning; cross-version rendering; resources referencing types no longer present in the provider.

Related errors


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

Appendix: source

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

	sf *statefile.File,
	schemas *terraform.Schemas,
) ([]byte, error) {
	output := newPlan()
	output.TerraformVersion = version.String()
	output.Timestamp = p.Timestamp.Format(time.RFC3339)
	output.Applyable = p.Applyable
	output.Complete = p.Complete
	output.Errored = p.Errored

	err := output.marshalPlanVariables(p.VariableValues, config.Module.Variables)
	if err != nil {
		return nil, fmt.Errorf("error in marshalPlanVariables: %s", err)
	}

	// output.PlannedValues
	err = output.marshalPlannedValues(p.Changes, schemas)
	if err != nil {
		return nil, fmt.Errorf("error in marshalPlannedValues: %s", err)
	}

	// output.ResourceDrift
	if len(p.DriftedResources) > 0 {
		// In refresh-only mode, we render all resources marked as drifted,
		// including those which have moved without other changes. In other plan
		// modes, move-only changes will be included in the planned changes, so
		// 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)
				}
			}
		}

View on GitHub (pinned to d32a084675)