{"record":{"id":"1f9d0ab66eaefe8e","repo":"testcontainers/testcontainers-java","slug":"missing-block-comment-end-delimiter-blockcommentenddelimiter","errorCode":null,"errorMessage":"Missing block comment end delimiter [blockCommentEndDelimiter].","messagePattern":"Missing block comment end delimiter \\[blockCommentEndDelimiter\\]\\.","errorType":"exception","errorClass":"ScriptParseException","httpStatus":null,"severity":"error","filePath":"modules/database-commons/src/main/java/org/testcontainers/ext/ScriptScanner.java","lineNumber":86,"sourceCode":"            if (m.find(offset)) {\n                currentMatch = commentPrefix + script.substring(offset, m.end());\n                offset = m.end();\n            } else {\n                currentMatch = commentPrefix + script.substring(offset);\n                offset = script.length();\n            }\n            return true;\n        }\n        return false;\n    }\n\n    private boolean matchesMultilineComment() {\n        /* Matches from blockCommentStartDelimiter to the next blockCommentEndDelimiter.\n         * Error, if blockCommentEndDelimiter is not found. */\n        if (matches(blockCommentStartDelimiter)) {\n            int end = script.indexOf(blockCommentEndDelimiter, offset);\n            if (end < 0) {\n                throw new ScriptUtils.ScriptParseException(\n                    String.format(\"Missing block comment end delimiter [%s].\", blockCommentEndDelimiter),\n                    resource\n                );\n            }\n            end += blockCommentEndDelimiter.length();\n            currentMatch = blockCommentStartDelimiter + script.substring(offset, end);\n            offset = end;\n            return true;\n        }\n        return false;\n    }\n\n    private boolean matchesQuotedString(final char quote) {\n        if (script.charAt(offset) == quote) {\n            boolean escaped = false;\n            for (int i = offset + 1; i < script.length(); i++) {\n                char c = script.charAt(i);\n                if (escaped) {","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/database-commons/src/main/java/org/testcontainers/ext/ScriptScanner.java#L68-L104","documentation":"ScriptScanner parses SQL init scripts and, upon encountering a block comment start delimiter (default /*), scans for the matching end delimiter (default */). If none exists before end of script, it throws ScriptUtils.ScriptParseException. The script file is malformed: a multi-line comment was opened but never closed.","triggerScenarios":"Executing an init script via withInitScript/executeDatabaseScript that contains '/*' with no matching '*/', or a custom blockCommentEndDelimiter that doesn't match what the script uses.","commonSituations":"Hand-edited SQL files where a comment close was deleted; copying scripts across dialects with different comment conventions; passing a wrong end-delimiter argument to executeDatabaseScript.","solutions":["Open the script at the reported resource and close every /* with */.","If the script intentionally uses a different comment terminator, pass matching blockCommentStartDelimiter/blockCommentEndDelimiter to executeDatabaseScript.","Lint the SQL files in CI to catch unbalanced comment delimiters before runtime."],"exampleFix":"// before (script.sql)\n/* TODO: fix this comment\nINSERT INTO users VALUES (1);\n// after (script.sql)\n/* TODO: fix this comment */\nINSERT INTO users VALUES (1);","handlingStrategy":"validation","validationCode":"String script = Files.readString(Path.of(\"src/test/resources/init.sql\"));\nif (countOccurrences(script, \"/*\") != countOccurrences(script, \"*/\")) {\n    throw new IllegalStateException(\"Unbalanced block comment delimiters in init.sql\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    ScriptUtils.executeDatabaseScript(delegate, path, script);\n} catch (ScriptUtils.ScriptParseException e) {\n    if (e.getMessage().contains(\"Missing block comment end delimiter\")) {\n        // surface the offending resource in test failure output\n    }\n    throw e;\n}","preventionTips":["Run SQL linters in CI to catch unbalanced comments.","Keep default delimiters /* and */ unless the whole toolchain agrees otherwise.","Review hand-edits to init scripts before committing."],"tags":["sql","script-parsing","comment-delimiter","init-script"],"backgroundTag":"schema-validation-failed","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}