xai-org/x-algorithm · error · ParseFailure

Failed to parse DF signature '%s'%s

Error message

Failed to parse DF signature '%s'%s

What it means

Thrown by Parser.parseParams when parsing a DF (dataflow/feature) signature string fails at the ANTLR level. Like the sibling errors, it appends line/column and unexpected-token context from the RecognitionException so the failure can be localized within the signature string.

Source

Thrown at botmaker/src/java/com/twitter/botmaker/compiler/Parser.java:157

    try {
      root = (Tree) parser.params().getTree();
    } catch (Exception e) {
      if (e.getCause() instanceof RecognitionException) {
        RecognitionException re = (RecognitionException) e.getCause();
        String extraMsg = "";
        if (re.token != null) {
          String unexpectedTok = "<EOF>";
          if (re.getUnexpectedType() >= 0) {
            unexpectedTok = BotMakerParser.tokenNames[re.getUnexpectedType()];
          }
          extraMsg = String.format(
              ": line %d col %d, near token <%s>: unexpected token %s",
              re.token.getLine(), re.token.getCharPositionInLine() + 1,
              re.token.getText(), unexpectedTok);
        } else if (re.line != 0) {
          extraMsg = String.format(": line %d col %d", re.line, re.charPositionInLine + 1);
        }
        throw new ParseFailure(String.format(
            "Failed to parse DF signature '%s'%s", s, extraMsg), re);
      }
      throw new ParseFailure("unknown parse failure", e);
    }

    return buildParams(root);
  }

  private static ImmutableList<Tuple3<Tree, String, Optional<Tree>>> buildParams(
      Tree params) throws ParseFailure {
    ImmutableList.Builder<Tuple3<Tree, String, Optional<Tree>>> ret = ImmutableList.builder();
    Set<String> argNames = Sets.newHashSet();
    boolean hasOpt = false;
    for (int i = 0; i < params.getChildCount(); i++) {
      Tree arg = params.getChild(i);
      if (arg.getType() == BotMakerLexer.ARG) {
        String name = arg.getChild(1).getText();
        if (arg.getChildCount() == 2 && hasOpt) {

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Correct the signature at the reported line/col/near-token location
  2. Verify argument list formatting (commas, parens, optional defaults) against working signatures in the repo/tests
  3. If this started after a grammar change, re-generate or update the signature strings to the new syntax
  4. Catch ParseFailure and report the full signature plus position to the author of the config

Example fix

// before
ImmutableList<Tuple3<Tree,String,Optional<Tree>>> ps = Parser.parseParams("#param(a #param(b");

// after
try {
  ImmutableList<Tuple3<Tree,String,Optional<Tree>>> ps = Parser.parseParams(sig);
} catch (ParseFailure pf) {
  throw new IllegalArgumentException("Invalid DF signature: " + sig, pf);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Reject obviously malformed DF signatures cheaply
boolean saneSignature(String sig) {
  return sig != null && sig.startsWith("#param") && looksBalanced(sig);
}

Try / catch

try {
  ImmutableList<Tuple3<Tree,String,Optional<Tree>>> ps = Parser.parseParams(sig);
} catch (ParseFailure pf) {
  throw new IllegalArgumentException("Invalid DF signature '" + sig + "': " + pf.getMessage(), pf);
}

Prevention

When it happens

Trigger: Calling parseParams (or params) with a DF signature containing unexpected tokens: bad argument list syntax, missing separators between args, invalid default-value syntax, or a truncated signature string.

Common situations: DF signatures authored by hand or assembled from configs; version upgrades of the grammar that change accepted signature syntax; copy/paste of signatures between environments with hidden character differences.

Understand the failure class

Related errors


AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28). Data as JSON: /api/errors/512d52229c6b1dde. Report an issue: GitHub.