OpenAPITools/openapi-generator · error · RuntimeException

Empty database/table/column name for property '{name}' not a

Error message

Empty database/table/column name for property '{name}' not allowed

What it means

MysqlSchemaCodegen sanitizes database/table/column names derived from the OpenAPI spec (stripping characters illegal in MySQL identifiers, trimming trailing spaces). If the sanitized result is empty, escapeMysqlIdentifier throws 'Empty database/table/column name ... not allowed' (MysqlSchemaCodegen.java:1099); all-digit or trailing-space names are only warned about and repaired. An empty identifier cannot be quoted or emitted, so generation aborts.

Source

Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/MysqlSchemaCodegen.java:1099

     * @return identifier name
     */
    public String toMysqlIdentifier(String name, String prefix, String suffix) {
        String escapedName = escapeMysqlQuotedIdentifier(name);
        // Database, table, and column names cannot end with space characters.
        if (escapedName.matches(".*\\s$")) {
            LOGGER.warn("Database, table, and column names cannot end with space characters. Check '{}' name", name);
            escapedName = escapedName.replaceAll("\\s+$", "");
        }

        // Identifiers may begin with a digit but unless quoted may not consist solely of digits.
        if (escapedName.matches("^\\d+$")) {
            LOGGER.warn("Database, table, and column names cannot consist solely of digits. Check '{}' name", name);
            escapedName = prefix + escapedName + suffix;
        }

        // identifier name cannot be empty
        if (escapedName.isEmpty()) {
            throw new RuntimeException("Empty database/table/column name for property '" + name + "' not allowed");
        }
        return escapedName;
    }

    /**
     * Escapes MySQL identifier to use it in SQL statements without backticks, eg. SELECT identifier FROM
     * Ref: https://dev.mysql.com/doc/refman/8.0/en/identifiers.html
     *
     * @param identifier source identifier
     * @return escaped identifier
     */
    public String escapeMysqlUnquotedIdentifier(String identifier) {
        // ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore) Extended: U+0080 .. U+FFFF
        Pattern regexp = Pattern.compile("[^0-9a-zA-z$_\\u0080-\\uFFFF]");
        Matcher matcher = regexp.matcher(identifier);
        if (matcher.find()) {
            LOGGER.warn("Identifier '{}' contains unsafe characters out of [0-9,a-z,A-Z$_] and U+0080..U+FFFF range",
                    identifier);

View on GitHub (pinned to fcec517be3)

Solutions

  1. Rename the offending property (named in the message) to a valid identifier (letter/underscore start, word characters).
  2. Add a spec lint step rejecting identifiers with no alphanumeric characters.
  3. Preprocess the spec to map symbolic names to safe names if the original keys must remain in the API contract.

Example fix

# before (api.yaml)
components:
  schemas:
    Order:
      properties:
        "$": { type: string }
# after
components:
  schemas:
    Order:
      properties:
        currency: { type: string }
Defensive patterns

Strategy: validation

Validate before calling

// mysql: reject keys with no valid identifier characters
Pattern nonWord = Pattern.compile("[^\\w]");
for (var schema : openAPI.getComponents().getSchemas().entrySet()) {
  if (schema.getValue().getProperties() == null) continue;
  for (String key : schema.getValue().getProperties().keySet()) {
    if (nonWord.matcher(key).replaceAll("").isEmpty()) {
      throw new IllegalArgumentException(
          "Property '" + key + "' sanitizes to an empty MySQL identifier");
    }
  }
}

Try / catch

try {
    new DefaultGenerator().opts(clientOptInput).generate();
} catch (RuntimeException e) {
    throw new BuildException("MySQL schema generation failed: " + e.getMessage(), e);
}

Prevention

When it happens

Trigger: A property/model/table name in the spec (or a mysql vendor-extension name) consisting entirely of characters that sanitization removes — symbols-only names like `$$$`, `###`, or whitespace-only keys — reaching escapeMysqlIdentifier() during mysql schema generation.

Common situations: Placeholder or i18n-derived field names in specs; spreadsheets/prototypes exported to OpenAPI with symbolic column headers; refactor scripts leaving keys like `-` or `*` behind.

Related errors


AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22). Data as JSON: /api/errors/c95d8f1d78ad6332. Report an issue: GitHub.