{"record":{"id":"c95d8f1d78ad6332","repo":"OpenAPITools/openapi-generator","slug":"empty-database-table-column-name-for-property-na-c95d8f","errorCode":null,"errorMessage":"Empty database/table/column name for property '{name}' not allowed","messagePattern":"Empty database/table/column name for property '(.+?)' not allowed","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/MysqlSchemaCodegen.java","lineNumber":1099,"sourceCode":"     * @return identifier name\n     */\n    public String toMysqlIdentifier(String name, String prefix, String suffix) {\n        String escapedName = escapeMysqlQuotedIdentifier(name);\n        // Database, table, and column names cannot end with space characters.\n        if (escapedName.matches(\".*\\\\s$\")) {\n            LOGGER.warn(\"Database, table, and column names cannot end with space characters. Check '{}' name\", name);\n            escapedName = escapedName.replaceAll(\"\\\\s+$\", \"\");\n        }\n\n        // Identifiers may begin with a digit but unless quoted may not consist solely of digits.\n        if (escapedName.matches(\"^\\\\d+$\")) {\n            LOGGER.warn(\"Database, table, and column names cannot consist solely of digits. Check '{}' name\", name);\n            escapedName = prefix + escapedName + suffix;\n        }\n\n        // identifier name cannot be empty\n        if (escapedName.isEmpty()) {\n            throw new RuntimeException(\"Empty database/table/column name for property '\" + name + \"' not allowed\");\n        }\n        return escapedName;\n    }\n\n    /**\n     * Escapes MySQL identifier to use it in SQL statements without backticks, eg. SELECT identifier FROM\n     * Ref: https://dev.mysql.com/doc/refman/8.0/en/identifiers.html\n     *\n     * @param identifier source identifier\n     * @return escaped identifier\n     */\n    public String escapeMysqlUnquotedIdentifier(String identifier) {\n        // ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore) Extended: U+0080 .. U+FFFF\n        Pattern regexp = Pattern.compile(\"[^0-9a-zA-z$_\\\\u0080-\\\\uFFFF]\");\n        Matcher matcher = regexp.matcher(identifier);\n        if (matcher.find()) {\n            LOGGER.warn(\"Identifier '{}' contains unsafe characters out of [0-9,a-z,A-Z$_] and U+0080..U+FFFF range\",\n                    identifier);","sourceCodeStart":1081,"sourceCodeEnd":1117,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/MysqlSchemaCodegen.java#L1081-L1117","documentation":"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.","triggerScenarios":"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.","commonSituations":"Placeholder or i18n-derived field names in specs; spreadsheets/prototypes exported to OpenAPI with symbolic column headers; refactor scripts leaving keys like `-` or `*` behind.","solutions":["Rename the offending property (named in the message) to a valid identifier (letter/underscore start, word characters).","Add a spec lint step rejecting identifiers with no alphanumeric characters.","Preprocess the spec to map symbolic names to safe names if the original keys must remain in the API contract."],"exampleFix":"# before (api.yaml)\ncomponents:\n  schemas:\n    Order:\n      properties:\n        \"$\": { type: string }\n# after\ncomponents:\n  schemas:\n    Order:\n      properties:\n        currency: { type: string }","handlingStrategy":"validation","validationCode":"// mysql: reject keys with no valid identifier characters\nPattern nonWord = Pattern.compile(\"[^\\\\w]\");\nfor (var schema : openAPI.getComponents().getSchemas().entrySet()) {\n  if (schema.getValue().getProperties() == null) continue;\n  for (String key : schema.getValue().getProperties().keySet()) {\n    if (nonWord.matcher(key).replaceAll(\"\").isEmpty()) {\n      throw new IllegalArgumentException(\n          \"Property '\" + key + \"' sanitizes to an empty MySQL identifier\");\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n    new DefaultGenerator().opts(clientOptInput).generate();\n} catch (RuntimeException e) {\n    throw new BuildException(\"MySQL schema generation failed: \" + e.getMessage(), e);\n}","preventionTips":["Lint spec keys against ^[A-Za-z0-9_]+$ before DDL generation.","Avoid symbolic/emoji column headers when exporting specs from spreadsheets.","Keep rename mappings in a preprocessing step if odd keys are unavoidable upstream."],"tags":["mysql","database-schema","identifier","sanitization","openapi-spec","openapi-generator","spec-validation"],"backgroundTag":"empty-identifier-after-sanitization","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}