{"record":{"id":"1a7fc335cc606775","repo":"mikefarah/yq","slug":"cannot-multiply-v-with-v","errorCode":null,"errorMessage":"cannot multiply %v with %v","messagePattern":"cannot multiply (.+?) with (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/yqlib/operator_multiply.go","lineNumber":97,"sourceCode":"\nfunc multiplyScalars(lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {\n\tlhsTag := lhs.Tag\n\trhsTag := rhs.guessTagFromCustomType()\n\tlhsIsCustom := false\n\tif !strings.HasPrefix(lhsTag, \"!!\") {\n\t\t// custom tag - we have to have a guess\n\t\tlhsTag = lhs.guessTagFromCustomType()\n\t\tlhsIsCustom = true\n\t}\n\n\tif lhsTag == \"!!int\" && rhsTag == \"!!int\" {\n\t\treturn multiplyIntegers(lhs, rhs)\n\t} else if (lhsTag == \"!!int\" || lhsTag == \"!!float\") && (rhsTag == \"!!int\" || rhsTag == \"!!float\") {\n\t\treturn multiplyFloats(lhs, rhs, lhsIsCustom)\n\t} else if (lhsTag == \"!!str\" && rhsTag == \"!!int\") || (lhsTag == \"!!int\" && rhsTag == \"!!str\") {\n\t\treturn repeatString(lhs, rhs)\n\t}\n\treturn nil, fmt.Errorf(\"cannot multiply %v with %v\", lhs.Tag, rhs.Tag)\n}\n\nfunc multiplyFloats(lhs *CandidateNode, rhs *CandidateNode, lhsIsCustom bool) (*CandidateNode, error) {\n\ttarget := lhs.CopyWithoutContent()\n\ttarget.Kind = ScalarNode\n\ttarget.Style = lhs.Style\n\tif lhsIsCustom {\n\t\ttarget.Tag = lhs.Tag\n\t} else {\n\t\ttarget.Tag = \"!!float\"\n\t}\n\n\tlhsNum, err := strconv.ParseFloat(lhs.Value, 64)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trhsNum, err := strconv.ParseFloat(rhs.Value, 64)\n\tif err != nil {","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/mikefarah/yq/blob/8b5af0694bb82b41d4ae180fac9972029066f90a/pkg/yqlib/operator_multiply.go#L79-L115","documentation":"yq's multiply operator ('*' expression) supports number*number and string*int (string repetition). multiplyScalars checks the tags of both operands and throws this error when the tag combination matches none of the supported cases (e.g. string*string, string*float, bool*int, null*string).","triggerScenarios":"Running a yq expression like '\"abc\" * \"def\"', '\"abc\" * 1.5', 'true * 2', or '\"abc\" * \"3\"' (RHS string not an !!int). Also occurs when a custom-typed tag cannot be guessed to int/float/str on either side.","commonSituations":"Unquoted numbers in YAML/JSON that were parsed as strings (e.g. version strings like '1.2' vs quoted '1.2'), environment/config values that are always strings, typos in expressions, or accidentally multiplying two strings expecting concatenation.","solutions":["Verify both operand types with 'yq -o=json' or 'tag' (e.g. '.x | tag'); ensure numeric operands are !!int/!!float","Convert string numbers before multiplying: '(.a | tonumber) * (.b | tonumber)' (or '@yaml' style '(.x | tag) == \"!!str\" | select(...) | .x | to_number' depending on version)","If you wanted string repetition, make sure one side is !!int and the other !!str, e.g. '\"-\" * 3'","If you wanted concatenation, use '+' instead of '*'"],"exampleFix":"// before (yq expression)\nyq '.msg * 3' file.yml        // fails if .msg is a quoted string number like \"4\"\n// after\nyq '(.msg | tonumber) * 3' file.yml","handlingStrategy":"validation","validationCode":"yq '.lhs | tag' f.yml && yq '.rhs | tag' f.yml  // ensure !!int/!!float pair, or !!str+!!int\n// shell guard:\n[[ \"$(yq '.x | tag' f.yml)\" =~ \"!!(int|float)\" ]] || echo \"convert with tonumber\"","typeGuard":"# yq expression guard\nyq 'select((.x | tag) == \"!!int\" or (.x | tag) == \"!!float\") | .x * 2' f.yml","tryCatchPattern":null,"preventionTips":["Check tags with '| tag' before arithmetic on document values","Use '| tonumber' on values that may be strings","Use '+' for concatenation, '*' only for numeric multiply or string*int repetition"],"tags":["yq","multiplication","type-mismatch","yaml"],"backgroundTag":"unsupported-operand-type","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"}