{"record":{"id":"d6c2d0791747af22","repo":"karatelabs/karate","slug":"expect-to-be-at-no-such-api-key","errorCode":null,"errorMessage":"expect().to.be.at - no such api: ${key}","messagePattern":"expect\\(\\)\\.to\\.be\\.at - no such api: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/match/Expect.java","lineNumber":216,"sourceCode":"    // ========== Chain Initializers ==========\n\n    private SimpleObject initExpectToBeAt() {\n        return key -> switch (key) {\n            case \"least\" -> handle(rhs -> {\n                if (subject instanceof Number actual && rhs instanceof Number expected) {\n                    return actual.doubleValue() >= expected.doubleValue() ? null : subject + \" is not at least: \" + rhs;\n                } else {\n                    return subject + \" is not at least: \" + rhs;\n                }\n            });\n            case \"most\" -> handle(rhs -> {\n                if (subject instanceof Number actual && rhs instanceof Number expected) {\n                    return actual.doubleValue() <= expected.doubleValue() ? null : subject + \" is not at most: \" + rhs;\n                } else {\n                    return subject + \" is not at most: \" + rhs;\n                }\n            });\n            default -> throw new RuntimeException(\"expect().to.be.at - no such api: \" + key);\n        };\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    private SimpleObject initExpectToBe() {\n        return key -> switch (key) {\n            case \"not\" -> new Expect(subject, !negated, onResult, throwOnFailure, contextSupplier).expectToBe;\n            case \"that\", \"and\", \"which\" -> this;\n            case \"a\", \"an\" -> handleChainable(rhs -> {\n                String expected = rhs + \"\";\n                String actual;\n                if (subject instanceof List) {\n                    actual = \"array\";\n                } else {\n                    actual = Terms.typeOf(subject);\n                }\n                return expected.equals(actual) ? null : \"actual: \" + actual + \", expected: \" + expected;\n            });","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/match/Expect.java#L198-L234","documentation":"The expect().to.be.at sub-API only supports comparison keys such as 'least' (>=) and 'most' (<=). An unknown key passed after .to.be.at makes initExpectToBeAt throw a RuntimeException naming the unsupported key.","triggerScenarios":"Calling expect(x).to.be.at.<key>(...) with a key not handled by the switch (anything other than the supported comparison keys like least/most), e.g. expect(5).to.be.at.greater(6) or a Chai-style key that Karate does not implement.","commonSituations":"Porting Chai.js assertions (e.g. above/below) to Karate without checking Karate's keyword set; typos like 'leat' or 'mos'; assuming richer Chai vocabulary exists.","solutions":["Use the supported keys: expect(x).to.be.at.least(n) / .at.most(n)","For strict comparisons use .to.be.above/.below equivalents or plain match syntax: match x == '#(_ > 6)'","Check docs for the exact expect() BDD keyword list"],"exampleFix":"// before\nexpect(5).to.be.at.above(4) // no such api: above\n// after\nexpect(5).to.be.at.least(5)","handlingStrategy":"validation","validationCode":"// only 'least' and 'most' are valid after .to.be.at\nvar validAtKeys = ['least', 'most'];\nkarate.match('at-key', key, '#(validAtKeys.includes(key) ? \"#string\" : \"#notpresent\")')\n// simpler: assert before using\nif (!validAtKeys.includes(key)) throw 'unsupported .to.be.at key: ' + key;","typeGuard":null,"tryCatchPattern":"try { expect(n).to.be.at.least(5); } catch (e) { karate.log('unsupported key: ' + e.message); }","preventionTips":["Memorize/verify the supported comparison keys: least, most","Never copy Chai's above/below/below-at-least vocabulary blindly","Let IDE/DSL autocompletion surface valid keys"],"tags":["expect","unsupported-key","bdd-assertion"],"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"}