{"record":{"id":"5a185773dbd16579","repo":"xai-org/x-algorithm","slug":"assert-failed","errorCode":null,"errorMessage":"Assert failed","messagePattern":"Assert failed","errorType":"validation","errorClass":"BotmakerAssertionException","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/function/exception/Assert.java","lineNumber":54,"sourceCode":"  }\n\n  @Override\n  protected CacheLevel getCacheLevel() {\n    return CacheLevel.Never;\n  }\n\n  public Assert(String exprText, ImmutableList<ASTNode> children) throws SemanticCheckFailure {\n    super(exprText, children);\n  }\n\n  @Override\n  public Object apply(Context<Runtime> context, List<Object> args) {\n\n    boolean bool = (boolean) args.get(0);\n    String message = args.size() > 1 ? (String) args.get(1) : \"Assert failed\";\n\n    if (!bool) {\n      throw new BotmakerAssertionException(message);\n    }\n\n    return 0L;\n  }\n\n  private static final class BotmakerAssertionException extends RuntimeException {\n\n    public BotmakerAssertionException(String message) {\n      super(message);\n    }\n\n    @Override public synchronized Throwable fillInStackTrace() {\n      return this;\n    }\n  }\n}\n","sourceCodeStart":36,"sourceCodeEnd":71,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/function/exception/Assert.java#L36-L71","documentation":"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.","triggerScenarios":"Assert(Equals(x, 1)) where x != 1 at runtime; Assert(IsNotEmpty(items)) on an empty list; any Assert whose boolean arg evaluates false.","commonSituations":"Debugging invariants left in production rules, defensive checks on data preconditions, or legit fail-fast logic firing due to bad upstream data.","solutions":["If the condition firing is expected, remove or weaken the Assert","Fix the upstream data/logic so the asserted invariant actually holds","Always pass a descriptive message as the second argument so failures are diagnosable"],"exampleFix":"// before\nAssert(Equals(status, \"ACTIVE\"))\n// after\nAssert(Equals(status, \"ACTIVE\"), \"expected ACTIVE status, got: \" + status)","handlingStrategy":"validation","validationCode":"// rule-language: branch instead of asserting on data-dependent conditions\nIf(Equals(status, \"ACTIVE\"), proceed, handleInactive)","typeGuard":null,"tryCatchPattern":"// host code: catch BotmakerAssertionException specifically, extract the custom message, and route to a monitoring/alerting path rather than generic retry","preventionTips":["Always pass a descriptive second message argument","Use Assert for invariants, not for normal business branching","Strip debug Asserts before promoting rules to production"],"tags":["botmaker","runtime","assert","invariant"],"backgroundTag":"assertion-failed","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}