{"record":{"id":"d2eb3a4bf19f258b","repo":"karatelabs/karate","slug":"invalid-octal-literal","errorCode":null,"errorMessage":"invalid octal literal","messagePattern":"invalid octal literal","errorType":"exception","errorClass":"ParserException","httpStatus":null,"severity":"error","filePath":"karate-js/src/main/java/io/karatelabs/parser/JsLexer.java","lineNumber":501,"sourceCode":"                scanBinaryDigitsWithSeparators();\n            }\n            if (!isAtEnd() && peek() == 'n') {\n                advance();\n                return BIGINT;\n            }\n            return NUMBER;\n        }\n\n        // Octal number (0o / 0O)\n        if (c == '0' && (peek(1) == 'o' || peek(1) == 'O')) {\n            advance(); // 0\n            advance(); // o\n            int octStart = pos;\n            while (!isAtEnd() && peek() >= '0' && peek() <= '7') {\n                advance();\n            }\n            if (pos == octStart) {\n                throw new ParserException(\"invalid octal literal\");\n            }\n            if (!isAtEnd() && peek() == '_') {\n                scanOctalDigitsWithSeparators();\n            }\n            if (!isAtEnd() && peek() == 'n') {\n                advance();\n                return BIGINT;\n            }\n            return NUMBER;\n        }\n\n        boolean isInteger = true;\n\n        // Decimal number\n        // Integer part\n        if (c == '.') {\n            // Number starting with .\n            isInteger = false;","sourceCodeStart":483,"sourceCodeEnd":519,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-js/src/main/java/io/karatelabs/parser/JsLexer.java#L483-L519","documentation":"The lexer throws this when an `0o`/`0O` octal prefix is not followed by any octal digit (0-7). ES2015 octal literals require at least one digit after the prefix. This is a tokenization-time ParserException.","triggerScenarios":"A JS expression contains `0o`, `0O`, `0o8`, `0o9`, or `0o_1` — the prefix is followed by a character outside 0-7 or by end of token.","commonSituations":"Porting old C-style octal code (`0755`) into ES-style octal incorrectly (`0o755` typo as `0o759`); permission-constant typos; dropped digits after manual edits.","solutions":["Provide a valid octal digit sequence after `0o` (e.g. `0o755`).","Use decimal instead if the value is 8 or 9 after the prefix (`0o8` is invalid — use `8`).","Verify every digit after `0o` is in 0-7.","If not meant as a number, quote it as a string."],"exampleFix":"// before\n* def mode = 0o8\n// after\n* def mode = 0o10","handlingStrategy":"validation","validationCode":"function isValidOctalLiteral(s) {\n  return /^0[oO][0-7]+n?$/.test(s.trim());\n}\nif (!isValidOctalLiteral(expr)) throw new Error('bad octal literal: ' + expr);","typeGuard":null,"tryCatchPattern":"try {\n  def x = eval(expr);\n} catch (e) {\n  if (e.message && e.message.indexOf('invalid octal literal') >= 0) {\n    karate.log('malformed octal literal: ' + expr);\n  }\n  throw e;\n}","preventionTips":["Ensure every 0o prefix is followed by digits 0-7 only.","Never put 8 or 9 in an octal literal.","Convert legacy 0-prefixed octals (0755) deliberately to 0o755.","Quote non-numeric text containing 0o as strings."],"tags":["javascript","lexer","numeric-literal"],"backgroundTag":"invalid-argument-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"}