{"record":{"id":"fb735deb82c34080","repo":"karatelabs/karate","slug":"missing-exponent-digits","errorCode":null,"errorMessage":"missing exponent digits","messagePattern":"missing exponent digits","errorType":"exception","errorClass":"ParserException","httpStatus":null,"severity":"error","filePath":"karate-js/src/main/java/io/karatelabs/parser/JsLexer.java","lineNumber":568,"sourceCode":"        char p = peek();\n        if (p == 'e' || p == 'E') {\n            isInteger = false;\n            advance();\n            if (peek() == '+' || peek() == '-') {\n                advance();\n            }\n            int expDigitsStart = pos;\n            while (!isAtEnd() && isDigit(peek())) {\n                advance();\n            }\n            if (!isAtEnd() && peek() == '_') {\n                if (pos == expDigitsStart) {\n                    throw new ParserException(\"invalid numeric separator\");\n                }\n                scanDigitsWithSeparators();\n            } else if (pos == expDigitsStart) {\n                // `1e`, `1.e+` — the exponent marker requires at least one digit\n                throw new ParserException(\"missing exponent digits\");\n            }\n        }\n\n        // Rare path: BigInt suffix — only valid on integer literals\n        if (isInteger && !isAtEnd() && peek() == 'n') {\n            advance();\n            return BIGINT;\n        }\n\n        return NUMBER;\n    }\n\n    // Slow path: number contained at least one `_` separator. Spec rules:\n    //   - `_` must appear between two digits (no leading, trailing, or doubled)\n    //   - the first `_` we see has already been validated (preceding char is a digit)\n    private void scanDigitsWithSeparators() {\n        while (!isAtEnd() && peek() == '_') {\n            advance(); // consume `_`","sourceCodeStart":550,"sourceCodeEnd":586,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-js/src/main/java/io/karatelabs/parser/JsLexer.java#L550-L586","documentation":"A numeric literal contains an exponent marker (`e` or `E`, optionally with sign) but no exponent digits follow. ECMAScript requires at least one digit after the exponent marker, so `1e`, `1.e+`, or `1e-` are rejected at tokenization time.","triggerScenarios":"Truncated scientific notation in embedded JS: `1e`, `2.5e+`, `1E-` — caused by incomplete typing, string interpolation cutting off the number, or a template like `1e${x}` where x is empty.","commonSituations":"Dynamic numeric construction via string concatenation where the exponent variable is empty; copy-paste truncation; accidental insertion of whitespace after `e` inside what should be one number token.","solutions":["Append the missing exponent digits (`1e` -> `1e10`, `1.e+` -> `1.5e+3`).","Remove the trailing `e`/`e+`/`e-` if the exponent was not intended.","If the value is dynamic, build the number in two parts: `1 * math.pow(10, n)` instead of string-forming `1e${n}`."],"exampleFix":"// before\n* def x = 1e\n// after\n* def x = 1e10","handlingStrategy":"validation","validationCode":"// exponent marker must be followed by at least one digit\nif (/[eE][+-]?$/.test(expr)) throw new Error('exponent missing digits: ' + expr);","typeGuard":null,"tryCatchPattern":"try {\n  def x = eval(expr);\n} catch (e) {\n  if (e.message && e.message.indexOf('missing exponent digits') >= 0) {\n    karate.log('incomplete scientific notation: ' + expr);\n  }\n  throw e;\n}","preventionTips":["Never build numeric literals via string interpolation with possibly-empty parts; compute with math instead.","Check for truncation after copy-paste of scientific notation.","Validate dynamic expressions with a regex before eval."],"tags":["javascript","lexer","numeric-literal"],"backgroundTag":"invalid-argument-format","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"}