{"record":{"id":"bf20037540f8ccde","repo":"karatelabs/karate","slug":"karate-markup-does-not-support-param-lists-in-th-fragment","errorCode":null,"errorMessage":"karate-markup does not support param lists in th:fragment signatures.\\n  Change   th:fragment=\"name(p1, p2)\"   ➜   th:fragment=\"name\"\\n  Pass values via th:with at the call site; ...\\n  Original Thymeleaf error: ${thymeleafMsg}","messagePattern":"karate-markup does not support param lists in th:fragment signatures\\.\\\\n  Change   th:fragment=\"name\\(p1, p2\\)\"   ➜   th:fragment=\"name\"\\\\n  Pass values via th:with at the call site; \\.\\.\\.\\\\n  Original Thymeleaf error: (.+?)","errorType":"exception","errorClass":"TemplateProcessingException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/markup/FragmentSupport.java","lineNumber":65,"sourceCode":" * </ul>\n */\nfinal class FragmentSupport {\n\n    private FragmentSupport() {\n    }\n\n    /**\n     * If the given Thymeleaf exception originated from strict-signature matching,\n     * throw a {@link TemplateProcessingException} whose message points at the\n     * karate-markup convention. Otherwise return without throwing — caller\n     * propagates the original.\n     */\n    static void translateSignatureError(TemplateProcessingException e) {\n        String msg = e.getMessage();\n        if (msg == null || !msg.contains(\"Cannot resolve fragment. Signature\")) {\n            return;\n        }\n        throw new TemplateProcessingException(signatureMessage(null, null, msg), e);\n    }\n\n    /**\n     * Build the karate-flavoured \"param lists not supported\" message. Used by\n     * both the proactive {@link KaFragmentProcessor} (which passes the offending\n     * attribute value) and {@link #translateSignatureError} (which only has the\n     * Thymeleaf message). Either argument may be {@code null}.\n     */\n    static String signatureMessage(String offendingValue, String resourceDescription, String thymeleafMsg) {\n        StringBuilder sb = new StringBuilder();\n        sb.append(\"karate-markup does not support param lists in th:fragment signatures.\\n\");\n        if (offendingValue != null) {\n            sb.append(\"  Found    th:fragment=\\\"\").append(offendingValue).append(\"\\\"\");\n            if (resourceDescription != null) {\n                sb.append(\"   in \").append(resourceDescription);\n            }\n            sb.append(\"\\n\");\n        }","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/markup/FragmentSupport.java#L47-L83","documentation":"karate-markup (KaThymeleaf) does not support parameter lists in th:fragment signatures, unlike stock Thymeleaf. When a fragment is declared with parameters, the library rewrites the raw Thymeleaf 'Cannot resolve fragment. Signature ...' error into this actionable message explaining the required change: declare the fragment without a parameter list and pass values via th:with at the call site.","triggerScenarios":"Rendering a template containing th:fragment=\"name(p1, p2)\" (a parameterized fragment signature), either detected proactively by KaFragmentProcessor or via a Thymeleaf TemplateProcessingException whose message contains 'Cannot resolve fragment. Signature'.","commonSituations":"Migrating existing Thymeleaf templates into karate-markup; copy-pasting standard Thymeleaf fragment examples from documentation; converting a layout system that relied on fragment parameters.","solutions":["Change the declaration to th:fragment=\"name\" (no parentheses)","Pass values at the call site with th:with=\"p1=..., p2=...\" instead of fragment arguments","Update all call sites (th:replace/th:insert) that used the parameterized form","Test template rendering to confirm the fragment resolves"],"exampleFix":"<!-- before -->\n<div th:fragment=\"card(title, body)\">...</div>\n<div th:replace=\"~{frag :: card('Hi', 'Text')}\"></div>\n<!-- after -->\n<div th:fragment=\"card\">...</div>\n<div th:replace=\"~{frag :: card}\" th:with=\"title='Hi', body='Text'\"></div>","handlingStrategy":"validation","validationCode":"Pattern SIG = Pattern.compile(\"th:fragment=\\\"([^\\\"]*)\\\\(([^\\\"]*)\\\\)\\\"\"); // scan templates; non-empty group(2) means param list -> fix before rendering","typeGuard":null,"tryCatchPattern":"try { render(template, model); } catch (TemplateProcessingException e) { if (e.getMessage() != null && e.getMessage().contains(\"th:fragment\")) { /* refactor fragment signature per message */ } throw e; }","preventionTips":["Write th:fragment=\"name\" without parentheses in karate-markup templates","Pass fragment inputs via th:with at the call site","Grep templates for 'th:fragment=\"' containing '(' in CI","Read the rewritten error message — it states the exact required change"],"tags":["template","thymeleaf","markup","fragment","migration"],"backgroundTag":"unsupported-operation","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"}