{"record":{"id":"7a47f84bc88abc06","repo":"OpenAPITools/openapi-generator","slug":"empty-database-table-column-name-for-property-na-7a47f8","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/PostgresqlSchemaCodegen.java","lineNumber":1335,"sourceCode":"     */\n    public String toPostgresqlIdentifier(String name, String prefix, String suffix) {\n        String escapedName = escapePostgresqlQuotedIdentifier(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\n        // 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 PostgreSQL identifier to use it in SQL statements without backticks,\n     * eg. SELECT identifier FROM\n     *\n     * @param identifier source identifier\n     * @return escaped identifier\n     */\n    public String escapePostgresqlUnquotedIdentifier(String identifier) {\n        // ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore)\n        // 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\",","sourceCodeStart":1317,"sourceCodeEnd":1353,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PostgresqlSchemaCodegen.java#L1317-L1353","documentation":"PostgresqlSchemaCodegen sanitizes database/table/column identifiers derived from the spec (removing characters illegal in PostgreSQL identifiers, trimming trailing spaces). Names that become empty after sanitization are fatal: escapePostgresqlIdentifier throws 'Empty database/table/column name ... not allowed' (PostgresqlSchemaCodegen.java:1335). Names that are all digits or end with spaces are only warned about and repaired; total emptiness cannot be repaired.","triggerScenarios":"A spec property/model/schema key (or postgres vendor-extension name) made entirely of characters sanitization strips — e.g. `###`, `$`, `***`, whitespace-only — reaching escapePostgresqlIdentifier() during postgresql schema generation.","commonSituations":"Symbolic column headers exported from spreadsheets into OpenAPI; placeholder keys left by refactors; specs authored for display (e.g. using symbols as labels) then reused for DDL generation.","solutions":["Rename the offending property (its name appears in the message) to a valid identifier.","Lint the spec for keys containing no alphanumeric characters before running the generator.","Introduce a preprocessing step mapping symbolic names to safe SQL identifiers if the API keys must stay unchanged."],"exampleFix":"# before (api.yaml)\ncomponents:\n  schemas:\n    Event:\n      properties:\n        \"***\": { type: string }\n# after\ncomponents:\n  schemas:\n    Event:\n      properties:\n        wildcard: { type: string }","handlingStrategy":"validation","validationCode":"// postgresql: reject keys that sanitize to an empty identifier\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 PostgreSQL identifier\");\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n    new DefaultGenerator().opts(clientOptInput).generate();\n} catch (RuntimeException e) {\n    throw new BuildException(\"PostgreSQL schema generation failed: \" + e.getMessage(), e);\n}","preventionTips":["Lint property/schema keys for at least one alphanumeric character.","Don't reuse display labels or symbols as schema keys in DDL-generating specs.","Add a preprocessing rename map for unavoidable symbolic keys."],"tags":["postgresql","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"}