{"record":{"id":"b7c7ffec4160a02d","repo":"karatelabs/karate","slug":"ka-dispatch-supports-a-single-event-trigger-delimiter-got","errorCode":null,"errorMessage":"ka:dispatch supports a single `event @ trigger` delimiter; got `${attributeValue}`","messagePattern":"ka:dispatch supports a single `event @ trigger` delimiter; got `(.+?)`","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/markup/KaDispatchProcessor.java","lineNumber":90,"sourceCode":"        super(TemplateMode.HTML, dialectPrefix, null, false, DISPATCH, true, 1000, true);\n    }\n\n    @Override\n    protected void doProcess(ITemplateContext ctx, IProcessableElementTag tag,\n                             AttributeName attributeName, String attributeValue,\n                             IElementTagStructureHandler structureHandler) {\n        // Split `<dispatched-event> @ <trigger-event>`. The `@`\n        // delimiter is optional; without it the dispatch fires on click\n        // (default, no htmx dependency). With it, the LHS is the CustomEvent\n        // name and the RHS is the DOM/htmx trigger emitted via\n        // `hx-on:<trigger>` (htmx must be loaded on the page).\n        String av = attributeValue.trim();\n        String eventName = av;\n        String triggerOn = null;\n        int at = av.indexOf('@');\n        if (at >= 0) {\n            if (av.lastIndexOf('@') != at) {\n                throw new RuntimeException(\n                        \"ka:dispatch supports a single `event @ trigger` delimiter; got `\"\n                                + attributeValue + \"`\");\n            }\n            eventName = av.substring(0, at).trim();\n            triggerOn = av.substring(at + 1).trim();\n            if (triggerOn.isEmpty()) {\n                throw new RuntimeException(\n                        \"ka:dispatch trigger must be non-empty after `@`; got `\"\n                                + attributeValue + \"`\");\n            }\n        }\n        if (eventName.isEmpty()) {\n            throw new RuntimeException(\n                    \"ka:dispatch requires an event name; got `\"\n                            + attributeValue + \"`\");\n        }\n        MarkupTemplateContext kec = (MarkupTemplateContext) ctx;\n        String detailJson = \"{}\";","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/markup/KaDispatchProcessor.java#L72-L108","documentation":"ka:dispatch's attribute value must be 'event @ trigger' with at most one '@' delimiter. doProcess trims the value and throws a RuntimeException when the value contains more than one '@', because the event/trigger split would be ambiguous. The full offending attribute value is included in the message.","triggerScenarios":"Writing ka:dispatch=\"evt@click @ other @ more\" or any value with two or more '@' characters; an email-like or URL-like trigger value that accidentally contains extra '@'.","commonSituations":"Putting an email address or '@handle' text inside the dispatch value; typos doubling the '@'; copy-paste joining two dispatch declarations on one line.","solutions":["Keep exactly one '@': ka:dispatch=\"eventName @ triggerEvent\"","Move extra '@'-containing text out of the attribute (e.g. into the event payload)","Escape or restructure dynamic values so they never inject additional '@' characters"],"exampleFix":"<!-- before -->\n<button ka:dispatch=\"save @form@submit\"></button>\n<!-- after -->\n<button ka:dispatch=\"save @ form-submit\"></button>","handlingStrategy":"validation","validationCode":"if (attrValue != null && attrValue.chars().filter(c -> c == '@').count() > 1) throw new IllegalArgumentException(\"ka:dispatch allows one '@', got: \" + attrValue);","typeGuard":null,"tryCatchPattern":"try { render(template, model); } catch (RuntimeException e) { if (e.getMessage() != null && e.getMessage().contains(\"single `event @ trigger`\")) { log.error(\"bad ka:dispatch: {}\", e.getMessage()); } throw e; }","preventionTips":["Use at most one '@' in ka:dispatch values","Never embed emails/handles containing '@' in the attribute","Validate dispatch attributes when generating templates dynamically"],"tags":["markup","attribute-validation","karate-markup","dispatch"],"backgroundTag":"invalid-argument-format","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}