{"record":{"id":"b5b16b354ef9b688","repo":"provectus/kafka-ui","slug":"script-syntax-error-e-getmessage","errorCode":null,"errorMessage":"Script syntax error: ${e.getMessage()}","messagePattern":"Script syntax error: (.+?)","errorType":"validation","errorClass":"ValidationException","httpStatus":400,"severity":"error","filePath":"kafka-ui-api/src/main/java/com/provectus/kafka/ui/emitter/MessageFilters.java","lineNumber":94,"sourceCode":"    } catch (Exception e) {\n      return str;\n    }\n  }\n\n  private static synchronized GroovyScriptEngineImpl getGroovyEngine() {\n    // it is pretty heavy object, so initializing it on-demand\n    if (GROOVY_ENGINE == null) {\n      GROOVY_ENGINE = (GroovyScriptEngineImpl)\n          new ScriptEngineManager().getEngineByName(\"groovy\");\n    }\n    return GROOVY_ENGINE;\n  }\n\n  private static CompiledScript compileScript(GroovyScriptEngineImpl engine, String script) {\n    try {\n      return engine.compile(script);\n    } catch (ScriptException e) {\n      throw new ValidationException(\"Script syntax error: \" + e.getMessage());\n    }\n  }\n\n}\n","sourceCodeStart":76,"sourceCodeEnd":99,"githubUrl":"https://github.com/provectus/kafka-ui/blob/83b5a60cc08501b570a0c4d0b4cdfceb1b88d6b7/kafka-ui-api/src/main/java/com/provectus/kafka/ui/emitter/MessageFilters.java#L76-L99","documentation":"MessageFilters.compileScript compiles the user's Groovy filter via a GroovyScriptEngineImpl. If the script has Groovy syntax errors, engine.compile throws ScriptException, which is rethrown as ValidationException with the underlying parser message, so the UI can show it to the user.","triggerScenarios":"Submitting a filter script with invalid Groovy syntax: unbalanced braces/quotes, reserved words, stray operators, e.g. `value == ` or `if (x { return true }`.","commonSituations":"Hand-typing complex filters in the small UI dialog; pasting Java-style code that isn't valid Groovy; quotes inside the script colliding with how the value was pasted from JSON/YAML.","solutions":["Fix the syntax error reported after 'Script syntax error:' — it includes line/column from Groovy","Balance all braces, parentheses, and string quotes in the script","Test the script in a Groovy console before pasting it into the filter dialog"],"exampleFix":"// before (script)\nvalue == null || (value.containsKey('a') && value['a'] > 5\n// after (script)\nvalue == null || (value.containsKey('a') && value['a'] > 5)","handlingStrategy":"try-catch","validationCode":"// pre-check in a Groovy shell before submitting to kafka-ui\ndef shell = new groovy.lang.GroovyShell()\ntry { shell.parse(script) } catch (Exception e) { throw new IllegalArgumentException(e.message) }","typeGuard":null,"tryCatchPattern":"try {\n  const filter = MessageFilters.compile(script);\n} catch (ValidationException e) {\n  if (e.getMessage().startsWith('Script syntax error:')) {\n    displayParserError(e.getMessage()); // includes Groovy line/column details\n  }\n}","preventionTips":["Validate the script in a local Groovy console before pasting into the UI","Keep filters short and prefer simple boolean expressions","Watch quotes: single quotes for literal strings, avoid unescaped nested quotes"],"tags":["groovy","syntax","filter","scripting"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"83b5a60cc08501b570a0c4d0b4cdfceb1b88d6b7","analyzedAt":"2026-09-08T04:35:39.002Z","contentChangedAt":"2026-09-08T04:35:39.002Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}