{"record":{"id":"27b8146c614b01b5","repo":"mikefarah/yq","slug":"v-not-yet-supported-for-contains","errorCode":null,"errorMessage":"%v not yet supported for contains","messagePattern":"(.+?) not yet supported for contains","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/yqlib/operator_contains.go","lineNumber":92,"sourceCode":"}\n\nfunc contains(lhs *CandidateNode, rhs *CandidateNode) (bool, error) {\n\tswitch lhs.Kind {\n\tcase MappingNode:\n\t\treturn containsObject(lhs, rhs)\n\tcase SequenceNode:\n\t\treturn containsArray(lhs, rhs)\n\tcase ScalarNode:\n\t\tif rhs.Kind != ScalarNode || lhs.Tag != rhs.Tag {\n\t\t\treturn false, nil\n\t\t}\n\t\tif lhs.Tag == \"!!null\" {\n\t\t\treturn rhs.Tag == \"!!null\", nil\n\t\t}\n\t\treturn containsScalars(lhs, rhs)\n\t}\n\n\treturn false, fmt.Errorf(\"%v not yet supported for contains\", lhs.Tag)\n}\n\nfunc containsWithNodes(_ *dataTreeNavigator, _ Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {\n\tif lhs.Kind != rhs.Kind {\n\t\treturn nil, fmt.Errorf(\"%v cannot check contained in %v\", rhs.Tag, lhs.Tag)\n\t}\n\n\tresult, err := contains(lhs, rhs)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn createBooleanCandidate(lhs, result), nil\n}\n","sourceCodeStart":74,"sourceCodeEnd":107,"githubUrl":"https://github.com/mikefarah/yq/blob/8b5af0694bb82b41d4ae180fac9972029066f90a/pkg/yqlib/operator_contains.go#L74-L107","documentation":"The yq `contains` operator only supports comparing mapping, sequence, and scalar nodes. When the left-hand node's kind is none of those (e.g. an alias/anchor node kind, or an unrecognised node kind), `contains()` falls through its switch and returns this error. It is a hard 'not implemented' guard, not a data mismatch.","triggerScenarios":"Running a `contains` expression where the LHS document node has a Kind other than MappingNode, SequenceNode, or ScalarNode (e.g. an unresolved alias node, kind 0/null-kind node, or a future node kind). The error bubbles up from containsArrayElement/containsObject when an element reached via recursion has such a kind.","commonSituations":"Feeding yq input in a format whose decoder produces exotic node kinds (e.g. tagged/aliased nodes in YAML), piping documents where a key resolves to an alias rather than a value, or using a very old/new yq version where node kinds differ. Very rare in normal use since YAML decoders mostly emit map/seq/scalar.","solutions":["Inspect the input node kind with `yq --debug-node-info` or print the tag (`.tag`) to see what unsupported kind the LHS holds","Dereference aliases before comparing (e.g. use `(.foo // empty)` or re-parse the input) so nodes are concrete map/seq/scalar values","Convert the value to a supported form first, e.g. force a scalar with `= .value` or select the concrete node instead of the anchor","If it happens on legitimately supported data, upgrade yq — this guard has shrunk as more kinds gained support"],"exampleFix":"// before: contains on an aliased node\nyq '.a contains \"x\"' <<< 'a: &val {b: x}'\n// after: dereference/return the concrete value first\nyq '(.a | .) contains {b: \"x\"}' <<< 'a: &val {b: x}'","handlingStrategy":"type-guard","validationCode":"// check kind before running contains in a yq pipeline\nyq 'select(type == \"!!map\" or type == \"!!seq\" or type == \"!!str\") | . contains (...)'\n// in Go embedding yqlib: switch node.Kind {\n// case yqlib.MappingNode, yqlib.SequenceNode, yqlib.ScalarNode: /* safe */\n// default: skip contains\n// }","typeGuard":"func containsSupported(n *yqlib.CandidateNode) bool {\n\tswitch n.Kind {\n\tcase yqlib.MappingNode, yqlib.SequenceNode, yqlib.ScalarNode:\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":null,"preventionTips":["Dereference YAML aliases before comparison so nodes are concrete map/seq/scalar","Print node tags with .tag or --debug-node-info when debugging odd inputs","Keep yq updated; supported kinds for contains have expanded over time","Validate input documents with a schema before running contains-style filters"],"tags":["yq","contains-operator","unsupported-type"],"backgroundTag":"unsupported-operation-for-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"}