{"record":{"id":"10c2d89b5d35fc94","repo":"xai-org/x-algorithm","slug":"unknown-parse-failure","errorCode":null,"errorMessage":"unknown parse failure","messagePattern":"unknown parse failure","errorType":"validation","errorClass":"ParseFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/compiler/Parser.java","lineNumber":160,"sourceCode":"      if (e.getCause() instanceof RecognitionException) {\n        RecognitionException re = (RecognitionException) e.getCause();\n        String extraMsg = \"\";\n        if (re.token != null) {\n          String unexpectedTok = \"<EOF>\";\n          if (re.getUnexpectedType() >= 0) {\n            unexpectedTok = BotMakerParser.tokenNames[re.getUnexpectedType()];\n          }\n          extraMsg = String.format(\n              \": line %d col %d, near token <%s>: unexpected token %s\",\n              re.token.getLine(), re.token.getCharPositionInLine() + 1,\n              re.token.getText(), unexpectedTok);\n        } else if (re.line != 0) {\n          extraMsg = String.format(\": line %d col %d\", re.line, re.charPositionInLine + 1);\n        }\n        throw new ParseFailure(String.format(\n            \"Failed to parse DF signature '%s'%s\", s, extraMsg), re);\n      }\n      throw new ParseFailure(\"unknown parse failure\", e);\n    }\n\n    return buildParams(root);\n  }\n\n  private static ImmutableList<Tuple3<Tree, String, Optional<Tree>>> buildParams(\n      Tree params) throws ParseFailure {\n    ImmutableList.Builder<Tuple3<Tree, String, Optional<Tree>>> ret = ImmutableList.builder();\n    Set<String> argNames = Sets.newHashSet();\n    boolean hasOpt = false;\n    for (int i = 0; i < params.getChildCount(); i++) {\n      Tree arg = params.getChild(i);\n      if (arg.getType() == BotMakerLexer.ARG) {\n        String name = arg.getChild(1).getText();\n        if (arg.getChildCount() == 2 && hasOpt) {\n          throw new ParseFailure(\n              String.format(\n                  \"Non-optional parameter %s must be declared before optional parameters.\",","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/compiler/Parser.java#L142-L178","documentation":"Fallback ParseFailure thrown by Parser.parseParams when the underlying exception is not a RecognitionException carrying position info. It indicates the parse blew up in a way the error-enrichment logic could not classify, so no line/column can be reported; the original exception is attached as the cause.","triggerScenarios":"parseParams hits a non-recognition exception from ANTLR: a null token, lexer error that escapes as a generic RuntimeException, or an internal error tree walk (e.g. buildParams on a malformed root) rather than a pure syntax error.","commonSituations":"Rare, ambiguous failures during grammar/runtime version mismatches (ANTLR version change altering exception types), corrupted generated parser classes, or edge-case inputs that crash the lexer instead of failing cleanly.","solutions":["Inspect the cause (e) chained on the ParseFailure — the real exception explains the failure","Reproduce with the exact input string in a unit test and narrow to the smallest failing fragment","Check for ANTLR/parser-class version mismatch after dependency upgrades","If the cause is a lexer crash, fix or reject the offending character sequence before parsing"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (ParseFailure pf) {\n  Throwable cause = pf.getCause();\n  log.error(\"Unknown parse failure; cause:\", cause);\n  // report input + cause to maintainers\n}","preventionTips":["Pin the ANTLR version used to generate the parser","Fuzz-test the parser with odd inputs to find lexer crashes","Always log the chained cause, not just the message"],"tags":["parsing","antlr","unknown-cause","botmaker"],"backgroundTag":"parse-error-unknown-cause","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}