{"record":{"id":"fd6810e4315e1466","repo":"mikefarah/yq","slug":"v-cannot-be-added-to-v","errorCode":null,"errorMessage":"%v cannot be added to %v","messagePattern":"(.+?) cannot be added to (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/yqlib/operator_add.go","lineNumber":145,"sourceCode":"\t\ttarget.Value = fmt.Sprintf(format, sum)\n\t} else if (lhsTag == \"!!int\" || lhsTag == \"!!float\") && (rhsTag == \"!!int\" || rhsTag == \"!!float\") {\n\t\tlhsNum, err := strconv.ParseFloat(lhs.Value, 64)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\trhsNum, err := strconv.ParseFloat(rhs.Value, 64)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tsum := lhsNum + rhsNum\n\t\tif lhsIsCustom {\n\t\t\ttarget.Tag = lhs.Tag\n\t\t} else {\n\t\t\ttarget.Tag = \"!!float\"\n\t\t}\n\t\ttarget.Value = fmt.Sprintf(\"%v\", sum)\n\t} else {\n\t\treturn fmt.Errorf(\"%v cannot be added to %v\", lhsTag, rhsTag)\n\t}\n\treturn nil\n}\n\nfunc addDateTimes(layout string, target *CandidateNode, lhs *CandidateNode, rhs *CandidateNode) error {\n\n\tduration, err := time.ParseDuration(rhs.Value)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to parse duration [%v]: %w\", rhs.Value, err)\n\t}\n\n\tcurrentTime, err := parseDateTime(layout, lhs.Value)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tnewTime := currentTime.Add(duration)\n\ttarget.Value = newTime.Format(layout)","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/mikefarah/yq/blob/8b5af0694bb82b41d4ae180fac9972029066f90a/pkg/yqlib/operator_add.go#L127-L163","documentation":"addScalars fell through every supported combination — its branches cover string+string, int/float+int/float, dates and custom-tag pairs. The left and right scalar tags (printed in the message, e.g. !!str and !!bool) have no addition defined, so the operator refuses rather than guessing a coercion.","triggerScenarios":"Thrown at pkg/yqlib/operator_add.go:145 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Convert operands to compatible types first (tostring, tonumber)","Check for accidental concatenation of string and number — use tostring on the number","For dates, ensure both sides are datetimes or a datetime plus a duration string"],"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"}