{"record":{"id":"41779ae6c3219256","repo":"karatelabs/karate","slug":"expect-to-have-any-no-such-api","errorCode":null,"errorMessage":"expect().to.have.any - no such api: ","messagePattern":"expect\\(\\)\\.to\\.have\\.any - no such api: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/match/Expect.java","lineNumber":361,"sourceCode":"            };\n            default -> throw new RuntimeException(\"expect().to.have.all - no such api: \" + key);\n        };\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    private SimpleObject initExpectToHaveAny() {\n        return key -> switch (key) {\n            case \"keys\" -> (JavaCallable) (context, args) -> {\n                Result result;\n                if (subject instanceof Map<?, ?> map) {\n                    result = evaluate(map.keySet(), Match.Type.CONTAINS_ANY, args[0]);\n                } else {\n                    result = Result.fail(\"not an object\");\n                }\n                handleResult(context, result);\n                return new Expect(subject, false, onResult, throwOnFailure, contextSupplier);\n            };\n            default -> throw new RuntimeException(\"expect().to.have.any - no such api: \" + key);\n        };\n    }\n\n    private SimpleObject initExpectToHaveNested() {\n        return key -> {\n            if (\"property\".equals(key)) {\n                return (JavaCallable) (context, args) -> {\n                    String path = args[0] + \"\";\n                    Json json;\n                    try {\n                        json = Json.of(subject);\n                    } catch (Exception e) {\n                        Result fail = Result.fail(\"expected to have property: \" + path);\n                        handleResult(context, fail);\n                        return new Expect(subject, false, onResult, throwOnFailure, contextSupplier);\n                    }\n                    Result result;\n                    if (args.length > 1) {","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/match/Expect.java#L343-L379","documentation":"Unknown-API sentinel in Expect's initExpectToHaveAny: the expect().to.have.any accessor is a switch over API key names (e.g. keys), and this fires when a property not in the switch is accessed after expect(...).to.have.any. The input at fault is the unrecognized key string appended to the message, indicating a typo or unsupported .have.any sub-API.","triggerScenarios":"expect(obj).to.have.any.<key>(...) with a key other than the supported one, e.g. .to.have.any.of(...) or .to.have.any.properties(...).","commonSituations":"Chai's .to.have.any.keys idiom mistyped as of/property; mixing Mocha/Chai vocabulary into Karate scripts.","solutions":["Use expect(obj).to.have.any.keys(['a','b']) exactly","Or use match syntax: match obj contains { a: '#present' }","Cross-check the keyword list; message prints the exact bad key"],"exampleFix":"// before\nexpect(obj).to.have.any.of(['a','b']) // no such api: of\n// after\nexpect(obj).to.have.any.keys(['a','b'])","handlingStrategy":"validation","validationCode":"if (key !== 'keys') throw 'only .to.have.any.keys is supported, got: ' + key;","typeGuard":null,"tryCatchPattern":"try { expect(obj).to.have.any.keys(['a','b']); } catch (e) { karate.log(e.message); }","preventionTips":["Use .to.have.any.keys(...) exactly; drop Chai's .of/.oneOf modifiers","Alternative: match obj contains { a: '#present' } for single-key checks"],"tags":["expect","unsupported-key","object-keys"],"backgroundTag":"invalid-enum-value","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}