{"record":{"id":"09094f6b427d8aba","repo":"conductor-oss/conductor","slug":"condition-exceeds-1024-characters","errorCode":null,"errorMessage":"condition exceeds 1024 characters","messagePattern":"condition exceeds 1024 characters","errorType":"validation","errorClass":"SafeConditionParseException","httpStatus":null,"severity":"error","filePath":"agentspan/src/main/java/org/conductoross/conductor/ai/agentspan/runtime/util/SafeConditionInterpreter.java","lineNumber":80,"sourceCode":" *\n * <p>If those ever need to be supported, extending the grammar requires adding a new node type with\n * a {@link Node#eval(Map)} implementation — the addition is auditable in code review rather than\n * silently re-opened by widening a regex.\n */\npublic final class SafeConditionInterpreter {\n\n    private SafeConditionInterpreter() {}\n\n    /** Maximum source length accepted by the parser. */\n    public static final int MAX_LENGTH = 1024;\n\n    // ── Public API ─────────────────────────────────────────────────\n\n    /** Parse a condition into an AST. Throws on syntax errors. */\n    public static Node parse(String src) {\n        if (src == null) throw new SafeConditionParseException(\"null condition\");\n        if (src.length() > MAX_LENGTH) {\n            throw new SafeConditionParseException(\n                    \"condition exceeds \" + MAX_LENGTH + \" characters\");\n        }\n        Parser p = new Parser(src);\n        Node ast = p.parseExpr();\n        p.expectEnd();\n        return ast;\n    }\n\n    /** Evaluate the parsed condition against a root map. */\n    public static boolean evaluate(String src, Map<String, Object> root) {\n        return truthy(parse(src).eval(root != null ? root : Map.of()));\n    }\n\n    /** True if and only if {@link #parse(String)} would accept this string. */\n    public static boolean isSafe(String src) {\n        try {\n            parse(src);\n            return true;","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/agentspan/src/main/java/org/conductoross/conductor/ai/agentspan/runtime/util/SafeConditionInterpreter.java#L62-L98","documentation":"SafeConditionInterpreter.parse throws when the condition string exceeds MAX_LENGTH (1024 characters). The cap exists to bound parse/eval work and to keep plan-supplied expressions auditable; an over-long expression usually indicates a generated or malformed payload rather than a hand-authored one.","triggerScenarios":"Passing a success_condition longer than 1024 chars to parse()/evaluate() — e.g. a giant inlined JSON literal, a base64 blob, or an accidentally-concatenated multi-condition string.","commonSituations":"A generator inlined a whole document as the condition; a copy-paste concatenated several conditions without operators; a templating bug produced a runaway string.","solutions":["Shorten the condition: reference fields from the root map (`$.foo`) instead of inlining large literals.","Split into multiple shorter conditions evaluated separately and combined in Java.","If a genuine long condition is required, raise MAX_LENGTH in the source after reviewing the security/perf implications."],"exampleFix":"// before: inlined JSON literal as condition, >1024 chars\nString cond = \"$.data == '{\\\"huge\\\":\\\"json\\\",...}'\";\n// after: compare a field extracted into the root map\nString cond = \"$.data.huge == 'json'\";","handlingStrategy":"validation","validationCode":"if (condition.length() > SafeConditionInterpreter.MAX_LENGTH) {\n    throw new IllegalArgumentException(\n        \"condition exceeds \" + SafeConditionInterpreter.MAX_LENGTH + \" characters\");\n}","typeGuard":"boolean isWithinLengthLimit(String s) {\n    return s != null && s.length() <= SafeConditionInterpreter.MAX_LENGTH;\n}","tryCatchPattern":"try { return SafeConditionInterpreter.parse(condition); }\ncatch (SafeConditionParseException e) {\n    if (e.getMessage().contains(\"exceeds\")) return badRequest(e.getMessage());\n    throw e;\n}","preventionTips":["Reference fields ($.) instead of inlining large literals.","Split long conditions and combine results in Java.","CI-lint plan files for condition length."],"tags":["agentspan","condition-interpreter","length-limit","validation"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}