{"record":{"id":"a66fa28b73fcbbdb","repo":"opentofu/opentofu","slug":"invalid-opresourceinstancecurrentmeta-instaddr-w","errorCode":null,"errorMessage":"invalid opResourceInstanceCurrentMeta instAddr: %w","messagePattern":"invalid opResourceInstanceCurrentMeta instAddr: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/engine/internal/execgraph/graph_unmarshal.go","lineNumber":160,"sourceCode":"\tcase opManagedChangeAddr:\n\t\treturn unmarshalOpManagedChangeAddr(protoOp.GetOperands(), prevResults, builder)\n\tcase opDataRead:\n\t\treturn unmarshalOpDataRead(protoOp.GetOperands(), prevResults, builder)\n\tdefault:\n\t\t// The above cases should cover all valid values of [opCode], so we\n\t\t// should not get here unless the serialized graph was tampered\n\t\t// with outside of OpenTofu.\n\t\treturn nil, fmt.Errorf(\"unrecognized opcode %d\", c)\n\t}\n}\n\nfunc unmarshalOpResourceInstanceCurrentMeta(rawOperands []uint64, prevResults []AnyResultRef, builder *Builder) (AnyResultRef, error) {\n\tif len(rawOperands) != 2 {\n\t\treturn nil, fmt.Errorf(\"wrong number of operands (%d) for opResourceInstanceCurrentMeta\", len(rawOperands))\n\t}\n\tinstAddr, err := unmarshalGetPrevResultOf[addrs.AbsResourceInstance](prevResults, rawOperands[0])\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid opResourceInstanceCurrentMeta instAddr: %w\", err)\n\t}\n\tprior, err := unmarshalGetPrevResultOf[*exec.ResourceInstanceObject](prevResults, rawOperands[1])\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid opResourceInstanceCurrentMeta prior: %w\", err)\n\t}\n\treturn builder.ResourceInstanceCurrentMeta(instAddr, prior), nil\n}\n\nfunc unmarshalOpResourceInstanceDesired(rawOperands []uint64, prevResults []AnyResultRef, builder *Builder) (AnyResultRef, error) {\n\tif len(rawOperands) != 1 {\n\t\treturn nil, fmt.Errorf(\"wrong number of operands (%d) for opResourceInstanceDesired\", len(rawOperands))\n\t}\n\tmeta, err := unmarshalGetPrevResultOf[*exec.ResourceInstanceObjectMeta](prevResults, rawOperands[0])\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid opResourceInstanceDesired meta: %w\", err)\n\t}\n\treturn builder.ResourceInstanceDesired(meta), nil\n}","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/opentofu/opentofu/blob/3561785c48c1ce615e7c50261bd351f26053efa2/internal/engine/internal/execgraph/graph_unmarshal.go#L142-L178","documentation":"The first operand of opResourceInstanceCurrentMeta must reference a previous element producing addrs.AbsResourceInstance. The wrapped 'refers to %T, but need %T' error means the referenced element yields a different result type (e.g. a ConstantValue). A forward reference or out-of-range index instead coerces to a nil result and does not raise this error.","triggerScenarios":"Operand index 0 points at an element of the wrong result type in a tampered or cross-version serialized graph.","commonSituations":"Version-skewed or hand-modified graph artifacts.","solutions":["Regenerate the graph artifact with the same OpenTofu version","Never modify serialized graphs between write and read","File an issue if the same released version both wrote and read the artifact"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"g, err := execgraph.UnmarshalGraph(src)\nif err != nil && strings.Contains(err.Error(), \"invalid opResourceInstanceCurrentMeta instAddr\") {\n\treturn fmt.Errorf(\"graph operand type mismatch (instAddr): %w\", err)\n}","preventionTips":["Never rewrite operand indexes in serialized graphs","Pin producer and consumer OpenTofu versions together","Add round-trip tests covering opResourceInstanceCurrentMeta"],"tags":["protobuf","graph","engine","type-mismatch","operands"],"backgroundTag":null,"analyzedSha":"3561785c48c1ce615e7c50261bd351f26053efa2","analyzedAt":"2026-08-15T23:27:16.226Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}