{"record":{"id":"f02fc42c5586a18c","repo":"mikefarah/yq","slug":"v-v-cannot-be-added-to-a-v-v","errorCode":null,"errorMessage":"%v (%v) cannot be added to a %v (%v)","messagePattern":"(.+?) \\((.+?)\\) cannot be added to a (.+?) \\((.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/yqlib/operator_add.go","lineNumber":66,"sourceCode":"func add(_ *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {\n\tlhsNode := lhs\n\n\tif lhs == nil && rhs == nil {\n\t\treturn nil, nil\n\t} else if lhs == nil {\n\t\treturn rhs.Copy(), nil\n\t} else if rhs == nil {\n\t\treturn lhs.Copy(), nil\n\t} else if lhsNode.Tag == \"!!null\" {\n\t\treturn lhs.CopyAsReplacement(rhs), nil\n\t}\n\n\ttarget := lhs.CopyWithoutContent()\n\n\tswitch lhsNode.Kind {\n\tcase MappingNode:\n\t\tif rhs.Kind != MappingNode {\n\t\t\treturn nil, fmt.Errorf(\"%v (%v) cannot be added to a %v (%v)\", rhs.Tag, rhs.GetNicePath(), lhsNode.Tag, lhs.GetNicePath())\n\t\t}\n\t\taddMaps(target, lhs, rhs)\n\tcase SequenceNode:\n\t\taddSequences(target, lhs, rhs)\n\tcase ScalarNode:\n\t\tif rhs.Kind != ScalarNode {\n\t\t\treturn nil, fmt.Errorf(\"%v (%v) cannot be added to a %v (%v)\", rhs.Tag, rhs.GetNicePath(), lhsNode.Tag, lhs.GetNicePath())\n\t\t}\n\t\ttarget.Kind = ScalarNode\n\t\ttarget.Style = lhsNode.Style\n\t\tif err := addScalars(context, target, lhsNode, rhs); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn target, nil\n}\n\nfunc addScalars(context Context, target *CandidateNode, lhs *CandidateNode, rhs *CandidateNode) error {","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/mikefarah/yq/blob/8b5af0694bb82b41d4ae180fac9972029066f90a/pkg/yqlib/operator_add.go#L48-L84","documentation":"Fired by the add operator's type guard when merging nodes: the left-hand operand is a mapping (!!map) but the right-hand operand is not, so yq cannot merge them. Only map+map (merge), string+string (concat), number+number (arithmetic), and array+array (append) combinations are supported; any map paired with a non-map hits this guard.","triggerScenarios":"Thrown at pkg/yqlib/operator_add.go:66 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure both operands are maps, e.g. `.a + .b` where both `.a` and `.b` are mappings","Convert the right-hand side before adding, e.g. `.a + (.b | to_entries | from_entries)` if it was parsed as a different type","Select a specific key to add instead of the whole node, e.g. `.target + .source.someField`"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8b5af0694bb82b41d4ae180fac9972029066f90a","analyzedAt":"2026-09-05T10:57:22.766Z","contentChangedAt":"2026-09-05T10:57:22.766Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}