[JDL/Enum]: Parsing issues with special chars / Missing quotes on export / JDL-injection with enums

Author: nitram84Created Oct 18, 2025Updated Sep 11, 2026
Labelsarea: triagetheme: undefined
##### **Overview of the issue** Summary: There are several issues with the jdl query parser, the way enum values are stored internally and on export - Enums like `QUOTES("\"")` or `COMMA_SPACE (", ")` , both correctly escaped and quoted, can't be imported - Enums with special chars won't be exported correctly. Jhipster export jdl generated no quotes for special characters. - Even JDL-injection with enums is possible causes by the way how enum values are stored internally. Examples and steps to reproduce: **Example 1:** Missing quotes on export and Enum injection The runnable examples use `EnumSample` instead of `Test` to avoid an unrelated Java test compilation conflict with JUnit's `Test` annotation. The original exported diagnostics below retain their original entity name. ##### **JHipster JDL** JDL definitions (Example 1)
application {
  config {
    applicationType monolith
    authenticationType jwt
    baseName jdlbugs
    buildTool maven
    cacheProvider ehcache
    clientFramework angular
    clientTheme none
    creationTimestamp 1760733393175
    databaseType sql
    devDatabaseType h2Disk
    enableHibernateCache true
    enableTranslation true
    jhipsterVersion "9.0.0-alpha.0"
    jwtSecretKey "ZjNhZDE2MGIxMDFkMGU5ZDI0ODE1ZmVkYjlmZjgxOTIyMzE4OGE1ODUyMGNmZjlmOTUyMGYxYTFkOTIzYzU2NzAxMWQyMjZiNzczOGJmYzZjOTE1MjIzMTUzYWViOTBmYTdlZmU3Y2RkOTVlY2U1NGRmOTRlMDJmMTc0MjI2MTg="
    languages [en]
    microfrontends []
    nativeLanguage en
    packageName com.mycompany.myapp
    prodDatabaseType postgresql
    reactive false
    testFrameworks []
    withAdminUi true
  }
  
  entities EnumSample
}

entity EnumSample {
  test SpecialChars
}

enum SpecialChars {
  Ue ("Ü") // special character, has to be quoted
  Try_to_inject_enum_in_entity_json("a), InjectedEnum(a")
}
  
Import enum-special-chars1.jdl: `jhipster import-jdl enum-special-chars1.jdl` Export Jdl: `jhipster export-jdl enum-special-chars-export.jdl` Result is: Incorrect exported output (Example 1, diagnostic only)
application {
  config {
    applicationType monolith
    authenticationType jwt
    baseName jdlbugs
    buildTool maven
    cacheProvider ehcache
    clientFramework angular
    clientTheme none
    creationTimestamp 1760733393175
    databaseType sql
    devDatabaseType h2Disk
    enableHibernateCache true
    enableTranslation true
    jhipsterVersion "9.0.0-alpha.0"
    jwtSecretKey "ZjNhZDE2MGIxMDFkMGU5ZDI0ODE1ZmVkYjlmZjgxOTIyMzE4OGE1ODUyMGNmZjlmOTUyMGYxYTFkOTIzYzU2NzAxMWQyMjZiNzczOGJmYzZjOTE1MjIzMTUzYWViOTBmYTdlZmU3Y2RkOTVlY2U1NGRmOTRlMDJmMTc0MjI2MTg="
    languages [en]
    microfrontends []
    nativeLanguage en
    packageName com.mycompany.myapp
    prodDatabaseType postgresql
    reactive false
    testFrameworks []
    withAdminUi true
  }

  entities Test
}

@ChangelogDate("20251017204639")
entity Test {
  test SpecialChars
}

enum SpecialChars {
  Ue (Ü),
  Try_to_inject_enum_in_entity_json (a),
  InjectedEnum(a)
}

search Test with no
  
Import exported jdl: `jhipster import-jdl enum-special-chars-export.jdl` results in this exception: ``` [..] Welcome to JHipster v9.0.0-alpha.0 INFO! Generating jdls enum-special-chars-export.jdl ERROR! An error occured while running jhipster:jdl#parseJDL ERROR! ERROR! unexpected character: ->Ü<- at offset: 881, skipped 1 characters. Error: unexpected character: ->Ü<- at offset: 881, skipped 1 characters. at getCst (generator-jhipster/dist/lib/jdl/core/parsing/api.js:31:15) at parse (generator-jhipster/dist/lib/jdl/core/parsing/api.js:24:17) at parse (generator-jhipster/dist/lib/jdl/core/readers/jdl-reader.js:78:31) at parseFromContent (generator-jhipster/dist/lib/jdl/core/readers/jdl-reader.js:44:12) at createImporterFromContent (generator-jhipster/dist/lib/jdl/jdl-importer.js:61:21) at JdlGenerator.parseJDL (generator-jhipster/dist/generators/jdl/generator.js:116:34) at JdlGenerator.executeTask (generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:265:26) at env.queueTask.once (generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:232:56) at runLoop.add.once (generator-jhipster/node_modules/yeoman-environment/dist/environment-base.js:383:23) at Immediate. (generator-jhipster/node_modules/grouped-queue/lib/subqueue.js:52:34) ``` **Example 2**: JDL parser can't handle quoted and escaped special characters correctly JDL definitions (Example 2)
application {
  config {
    applicationType monolith
    authenticationType jwt
    baseName jdlbugs
    buildTool maven
    cacheProvider ehcache
    clientFramework angular
    clientTheme none
    creationTimestamp 1760733393175
    databaseType sql
    devDatabaseType h2Disk
    enableHibernateCache true
    enableTranslation true
    jhipsterVersion "9.0.0-alpha.0"
    jwtSecretKey "ZjNhZDE2MGIxMDFkMGU5ZDI0ODE1ZmVkYjlmZjgxOTIyMzE4OGE1ODUyMGNmZjlmOTUyMGYxYTFkOTIzYzU2NzAxMWQyMjZiNzczOGJmYzZjOTE1MjIzMTUzYWViOTBmYTdlZmU3Y2RkOTVlY2U1NGRmOTRlMDJmMTc0MjI2MTg="
    languages [en]
    microfrontends []
    nativeLanguage en
    packageName com.mycompany.myapp
    prodDatabaseType postgresql
    reactive false
    testFrameworks []
    withAdminUi true
  }
  
  entities EnumSample
}

entity EnumSample {
  test SpecialChars2
}

enum SpecialChars2 {
  ESCAPING_WORKS("\\")
  ESCAPED_QUOTES_FAIL("\"")
}
  
`jhipster import-jdl enum-special-chars2.jdl` results in this exception: ``` Welcome to JHipster v9.0.0-alpha.0 INFO! Generating jdls enum-special-chars.jdl ERROR! An error occured while running jhipster:jdl#parseJDL ERROR! ERROR! unexpected character: ->"<- at offset: 892, skipped 1 characters. Error: unexpected character: ->"<- at offset: 892, skipped 1 characters. at getCst (generator-jhipster/dist/lib/jdl/core/parsing/api.js:31:15) at parse (generator-jhipster/dist/lib/jdl/core/parsing/api.js:24:17) at parse (generator-jhipster/dist/lib/jdl/core/readers/jdl-reader.js:78:31) at parseFromContent (generator-jhipster/dist/lib/jdl/core/readers/jdl-reader.js:44:12) at createImporterFromContent (generator-jhipster/dist/lib/jdl/jdl-importer.js:61:21) at JdlGenerator.parseJDL (generator-jhipster/dist/generators/jdl/generator.js:116:34) at JdlGenerator.executeTask (generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:265:26) at env.queueTask.once (generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:232:56) at runLoop.add.once (generator-jhipster/node_modules/yeoman-environment/dist/environment-base.js:383:23) at Immediate. (generator-jhipster/node_modules/grouped-queue/lib/subqueue.js:52:34) ``` **Example 3**: JDL parser can't handle enum values with comma and space JDL definitions (Example 3)
application {
  config {
    applicationType monolith
    authenticationType jwt
    baseName jdlbugs
    buildTool maven
    cacheProvider ehcache
    clientFramework angular
    clientTheme none
    creationTimestamp 1760733393175
    databaseType sql
    devDatabaseType h2Disk
    enableHibernateCache true
    enableTranslation true
    jhipsterVersion "9.0.0-alpha.0"
    jwtSecretKey "ZjNhZDE2MGIxMDFkMGU5ZDI0ODE1ZmVkYjlmZjgxOTIyMzE4OGE1ODUyMGNmZjlmOTUyMGYxYTFkOTIzYzU2NzAxMWQyMjZiNzczOGJmYzZjOTE1MjIzMTUzYWViOTBmYTdlZmU3Y2RkOTVlY2U1NGRmOTRlMDJmMTc0MjI2MTg="
    languages [en]
    microfrontends []
    nativeLanguage en
    packageName com.mycompany.myapp
    prodDatabaseType postgresql
    reactive false
    testFrameworks []
    withAdminUi true
  }
  
  entities EnumSample
}

entity EnumSample {
  test SpecialChars2
}

enum SpecialChars2 {
  COMMA_SPACE_CANNOT_BE_PARSED (", ")
}
  
`jhipster import-jdl enum-special-chars3.jdl` results in this exception: ``` Welcome to JHipster v9.0.0-alpha.0 INFO! Generating jdls enum-special-chars3.jdl info Generating 1 application _______________________________________________________________________________________________________________ Documentation for creating an application is at https://www.jhipster.tech/creating-an-app/ Application files will be generated in folder: /home/martin/Jhipster/jdlbugs _______________________________________________________________________________________________________________ ERROR! An error occured while running jhipster:base-application:bootstrap#prepareFieldsForTemplates ERROR! ERROR! Cannot read properties of null (reading '1') TypeError: Cannot read properties of null (reading '1') at generator-jhipster/dist/generators/base-application/support/prepare-field.js:338:26 at Array.map () at getEnumValuesWithCustomValues (generator-jhipster/dist/generators/base-application/support/prepare-field.js:332:34) at prepareCommonFieldForTemplates (generator-jhipster/dist/generators/base-application/support/prepare-field.js:266:28) at BootstrapBaseApplicationGenerator.prepareFieldsForTemplates (generator-jhipster/dist/generators/base-application/generators/bootstrap/generator.js:303:17) at BootstrapBaseApplicationGenerator.executeTask (generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:265:26) at env.queueTask.once (generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:232:56) at runLoop.add.once (generator-jhipster/node_modules/yeoman-environment/dist/environment-base.js:383:23) at Immediate. (/home/martin/Jhipster/generator-jhipster/node_modules/grouped-queue/lib/subqueue.js:52:34) at process.processImmediate (node:internal/timers:491:21) ``` - [x] JDL is mandatory for bug reports. This will allow us to use automated tests and generate the broken sample using `jhipster from-issue` command. ##### **Motivation for or Use Case** - The JDL parser should handle special characters in enum values. - Special characters in enum values should be exported correctly. - JDL-injection should not be possible ##### **Reproduce the error** ##### **Related issues** ##### **Suggest a Fix** The root cause for these issues is how fieldValues for enum are stored. This explains how injection is possible. Jhipster removes all quotes because a single string is used to store enum data: ``` { "annotations": { "changelogDate": "20251017204639" }, "applications": ["jdlbugs"], "fields": [ { "fieldName": "umlaut", "fieldType": "SpecialChars", "fieldValues": "Ue (Ü),Try_to_inject_enum_in_entity_json (a),InjectedEnum(a)" } ], "name": "Test", "relationships": [], "searchEngine": "no" } ``` Parsing a single string for enum values correctly is very complex. I suggest using an array or JSON in general e.q. ``` { "annotations": { "changelogDate": "20251017204639" }, "applications": ["jdlbugs"], "fields": [ { "fieldName": "umlaut", "fieldType": "SpecialChars", "fieldValues": [ { "enumFieldName": "Ue", "enumFieldValue": "Ü" } { "enumFieldName": "Try_to_inject_enum_in_entity_json", "enumFieldValue": "a),InjectedEnum(a" } ] } ], "name": "Test", "relationships": [], "searchEngine": "no" } ``` Injection will fail and exporting with quotes will become simple: If "enumValue" contains a non alphanumeric value, then enumValue has to be exported in qoutes. ##### **JHipster Version(s)** JHipster v9.0.0-alpha.0, v9.0.0, latest git version ##### **Browsers and Operating System** - [x] Tickets opened without reproduction steps or that doesn't follows the template recommendation will be **closed**. - [x] Checking this box is mandatory (this is just to show you read everything)

Source: jhipster/generator-jhipster