templates: escape an authored check/guard/unique/refuse message into the Java literal it lands in (#7241) - #7262
Merged
Conversation
…the Java literal it lands in (#7241) #7205 (#7154) added JavaLiterals.escape and wired it into exactly one site - the authored dataDefaultValue. Every other authored string the templates write into a Java string literal was still interpolated verbatim, so a quote or a backslash in one ended that literal and failed javac for the WHOLE generated module, not just the class carrying the message: the repository's guard and document checks, the row checks and unique-key messages of all three controllers, and a create-from's items refusal. A message in the shape the DSL's own examples suggest - `A "due" date is never before the invoice date` - therefore took every entity of the module down, at publish, in the Problems view. ModelParameterProcessor now puts an escaped twin on every check map it already walks (messageJavaLiteral, reaching the row / guard / document lists alike) and on each unique constraint (messageJavaLiteral + nameJavaLiteral), and GlueGenerator does the same for itemRefuse; the raw value stays for the surfaces that render it as text, and only the Java sites read the twin. A holder carrying no message is left without a twin, as the default-value literal is - the key's absence is what a template reads. The .edm XML and the .model JSON already escape these values, so the fix is confined to the Java emission. Verified: mvn formatter:validate over the reactor with the caches wiped; the ide-template unit suite (two new ModelParameterProcessorTest cases pinning the twins and their absence); IntentEmissionCoverageIT, whose fixture now carries a quote in a document check, a row check, a unique key, a guard and an items refusal - it generates, compiles and RUNS the module, and asserts both the escaped form in the emitted source and the authored form in the runtime message the caller is answered with. With one template site reverted to the raw value the IT fails on that assertion, so the pin bites. The release-profile javadoc build passes on ide-template. Not verified: the rest of the integration suite, and PostgreSQL. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… twin (#7241) Two template ITs build the parameter map by hand rather than through ModelParameterProcessor, so they kept the pre-#7241 shape and rendered an empty message at the Java site: - PersonalSurfaceCreateValidationTemplateIT's row check now carries `messageJavaLiteral` alongside the raw message. - UniqueFieldConflictControllerTemplateIT's composite key now carries `nameJavaLiteral` + `messageJavaLiteral`, and its authored message QUOTES the field it is about - the shape the defect is about. That test compiles and runs the rendered mapping, so the fixture is a real pin, not a restatement: with the controller template reverted to `${uniqueConstraint.message}` the extracted mapping fails to compile, and with the twin restored it is green again. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…uthored-messages # Conflicts: # tests/tests-integrations/src/main/java/org/eclipse/dirigible/integration/tests/api/IntentEmissionCoverageIT.java
This was referenced Sep 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cause
#7205 (#7154) introduced
JavaLiterals.escape/defaultValueExpressionand wired it into exactly one site — the authoreddataDefaultValue. Every other authored string the templates write into a Java string literal was still interpolated verbatim, so a"or a\in one ended that literal and failedjavacfor the whole generated module, not merely the class carrying the message:template-application-dao-javaRepository.java.templatethrow new ValidationException("${guard.message}")and the three"${check.message}"document gatestemplate-application-rest-javaEntity{,My,Partner}Controller.java.template"${check.message}"refusals andmessages.put("${uniqueConstraint.name}"…, "${uniqueConstraint.message}")template-application-events-javaGenerate.java.template"${itemRefuse} (${fromItemEntity} " + unqualified + ")"A message in the shape the DSL's own issues suggest —
message: 'A "due" date is never before the invoice date'— therefore took every entity of the module down, at publish, in the Problems view, and nothing in the parser refused it.Change
ModelParameterProcessoralready walks the checks it splits intorowChecks/guardChecks/documentChecks; it now puts an escaped twin on each check map (messageJavaLiteral) and on each unique constraint (messageJavaLiteral+nameJavaLiteral), andGlueGeneratordoes the same foritemRefuse(itemRefuseJavaLiteral). The templates read the twin at the Java sites only — the raw value stays in place for the surfaces that render it as text, which is why the twin was preferred over escaping in place (uniqueConstraint.nameis also written into the.schemaJSON). A holder carrying no message is left without a twin rather than an empty one, exactly asdataDefaultValueJavaLiteralis: the key's absence is what a template reads.The
.edmXML (escapeXmlText/escapeXml) and the.modelJSON (JsonHelper.toJson) already escape these values, so the defect and the fix are confined to the Java emission.Verification
mvn -T 1C formatter:validateover the reactor with everyformatter-maven-cache.propertiesdeleted first — BUILD SUCCESS.mvn -pl components/ide/ide-template -am test— green, including two newModelParameterProcessorTestcases: one pinning the escaped twins of a row check, a guard, a document check and a unique key (quote and backslash), one pinning that a holder with no message gets no twin.IntentEmissionCoverageIT— green. Its fixture now carries a quote in all five families: a document check (itemsMin), a row check (compare), a unique key, a guard and a create-fromrefuse:. The IT generates, publishes, compiles and runs the module, and asserts both halves: the escaped form in the emitted source, and the authored form in the runtime message the caller is answered with (.body("message", containsString(…))on the two 400s).${check.message}the IT fails on the new assertion; restored, it is green again.mvn -P release …javadoc build oncomponents/ide/ide-template— BUILD SUCCESS.Not verified: the rest of the integration suite, and the PostgreSQL leg.
Siblings, not addressed here: #7206 (the
.schemaJSON), #7207 (JS).Fixes #7241
🤖 Generated with Claude Code