xai-org/x-algorithm · error · BotmakerAssertionException

Assert failed

Error message

Assert failed

What it means

Assert(condition[, message]) throws BotmakerAssertionException when the first argument evaluates to false; the message defaults to 'Assert failed' when omitted. This is an intentional, user-triggered failure used to abort rule execution on invariant violations.

Source

Thrown at botmaker/src/java/com/twitter/botmaker/function/exception/Assert.java:54

  }

  @Override
  protected CacheLevel getCacheLevel() {
    return CacheLevel.Never;
  }

  public Assert(String exprText, ImmutableList<ASTNode> children) throws SemanticCheckFailure {
    super(exprText, children);
  }

  @Override
  public Object apply(Context<Runtime> context, List<Object> args) {

    boolean bool = (boolean) args.get(0);
    String message = args.size() > 1 ? (String) args.get(1) : "Assert failed";

    if (!bool) {
      throw new BotmakerAssertionException(message);
    }

    return 0L;
  }

  private static final class BotmakerAssertionException extends RuntimeException {

    public BotmakerAssertionException(String message) {
      super(message);
    }

    @Override public synchronized Throwable fillInStackTrace() {
      return this;
    }
  }
}

View on GitHub (pinned to 24c60942c5)

Solutions

  1. If the condition firing is expected, remove or weaken the Assert
  2. Fix the upstream data/logic so the asserted invariant actually holds
  3. Always pass a descriptive message as the second argument so failures are diagnosable

Example fix

// before
Assert(Equals(status, "ACTIVE"))
// after
Assert(Equals(status, "ACTIVE"), "expected ACTIVE status, got: " + status)
Defensive patterns

Strategy: validation

Validate before calling

// rule-language: branch instead of asserting on data-dependent conditions
If(Equals(status, "ACTIVE"), proceed, handleInactive)

Try / catch

// host code: catch BotmakerAssertionException specifically, extract the custom message, and route to a monitoring/alerting path rather than generic retry

Prevention

When it happens

Trigger: Assert(Equals(x, 1)) where x != 1 at runtime; Assert(IsNotEmpty(items)) on an empty list; any Assert whose boolean arg evaluates false.

Common situations: Debugging invariants left in production rules, defensive checks on data preconditions, or legit fail-fast logic firing due to bad upstream data.

Related errors


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