{"record":{"id":"e5ad5dd864a82100","repo":"opentofu/opentofu","slug":"wrong-number-of-operands-d-for-opmanagedalready","errorCode":null,"errorMessage":"wrong number of operands (%d) for opManagedAlreadyDeposed","messagePattern":"wrong number of operands \\((.+?)\\) for opManagedAlreadyDeposed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/engine/internal/execgraph/graph_unmarshal.go","lineNumber":288,"sourceCode":"\t}\n\tinstAddr, err := unmarshalGetPrevResultOf[addrs.AbsResourceInstance](prevResults, rawOperands[0])\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid unmarshalOpManagedDeposedMeta instAddr: %w\", err)\n\t}\n\tdeposedKey, err := unmarshalGetPrevResultOf[states.DeposedKey](prevResults, rawOperands[1])\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid unmarshalOpManagedDeposedMeta deposedKey: %w\", err)\n\t}\n\tprior, err := unmarshalGetPrevResultOf[*exec.ResourceInstanceObject](prevResults, rawOperands[2])\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid unmarshalOpManagedDeposedMeta prior: %w\", err)\n\t}\n\treturn builder.ManagedDeposedMeta(instAddr, deposedKey, prior), nil\n}\n\nfunc unmarshalOpManagedAlreadyDeposed(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 opManagedAlreadyDeposed\", len(rawOperands))\n\t}\n\tinstAddr, err := unmarshalGetPrevResultOf[addrs.AbsResourceInstance](prevResults, rawOperands[0])\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid opManagedAlreadyDeposed instAddr: %w\", err)\n\t}\n\tdeposedKey, err := unmarshalGetPrevResultOf[states.DeposedKey](prevResults, rawOperands[1])\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid opManagedAlreadyDeposed deposedKey: %w\", err)\n\t}\n\treturn builder.ManagedAlreadyDeposed(instAddr, deposedKey), nil\n}\n\nfunc unmarshalOpManagedChangeAddr(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 opManagedChangeAddr\", len(rawOperands))\n\t}\n\tcurrentObj, err := unmarshalGetPrevResultOf[*exec.ResourceInstanceObject](prevResults, rawOperands[0])\n\tif err != nil {","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/opentofu/opentofu/blob/3561785c48c1ce615e7c50261bd351f26053efa2/internal/engine/internal/execgraph/graph_unmarshal.go#L270-L306","documentation":"UnmarshalGraph rejects an opManagedAlreadyDeposed element whose operand list does not contain exactly 2 entries (instAddr, deposedKey). The operand count is fixed by the operation's contract with the Builder.ManagedAlreadyDeposed call, so any other count means the serialized payload does not follow the format this OpenTofu build expects.","triggerScenarios":"UnmarshalGraph reads an element whose WhichRequest() is Operation with the ManagedAlreadyDeposed opcode and len(rawOperands) != 2 — e.g. 0, 1, or 3+ operands in the protobuf operation record.","commonSituations":"Serialized graph written by an incompatible OpenTofu version that changed the operation signature; corrupted or hand-crafted protobuf operation records; partial writes leaving malformed fields.","solutions":["Regenerate the graph artifact with the same OpenTofu version that reads it","Check the artifact's integrity (hash) and replace it if corrupted","Confirm producer and consumer versions match before exchanging serialized graphs","If produced by Graph.Marshal unmodified, report the Marshal/Unmarshal mismatch as an OpenTofu bug"],"exampleFix":"// before: custom marshaler emits 3 operands for ManagedAlreadyDeposed\nop := &execgraphproto.Operation{Operands: []uint64{instAddrIdx, deposedKeyIdx, extraIdx}}\n// after: emit exactly the two operands the operation requires\nop := &execgraphproto.Operation{Operands: []uint64{instAddrIdx, deposedKeyIdx}}","handlingStrategy":"validation","validationCode":"// Producers: assert operand counts before serializing each operation.\nif len(operands) != 2 {\n    return fmt.Errorf(\"opManagedAlreadyDeposed needs 2 operands, got %d\", len(operands))\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    // operand-count errors mean the artifact is unusable: regenerate, don't retry\n    return fmt.Errorf(\"rejecting execution graph artifact: %w\", err)\n}","preventionTips":["Pin graph producers and consumers to the same OpenTofu build","Add round-trip tests (Marshal then Unmarshal) for every operation type you emit","Reject artifacts whose protobuf schema version differs from the reader's"],"tags":["serialization","execgraph","unmarshal","operands","go"],"backgroundTag":null,"analyzedSha":"3561785c48c1ce615e7c50261bd351f26053efa2","analyzedAt":"2026-08-15T23:27:16.226Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}