{"record":{"id":"b12079cb035e72c5","repo":"OtterMind/Chat2DB","slug":"unsupported-varchar-unit-unit","errorCode":null,"errorMessage":"Unsupported VARCHAR unit: {unit}","messagePattern":"Unsupported VARCHAR unit: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"chat2db-community-server/chat2db-community-plugins/chat2db-community-sundb/src/main/java/ai/chat2db/plugin/sundb/SUNDBSqlGuards.java","lineNumber":96,"sourceCode":"            throw invalid(\"column type\", columnType);\n        }\n        scanExpression(trimmed, true, \"column type\");\n        return trimmed;\n    }\n\n    /**\n     * Validates a VARCHAR size unit: only CHAR/BYTE are legal. Anything else is\n     * rejected to block DDL injection.\n     */\n    public static String requireUnit(String unit) {\n        String trimmed = StringUtils.trimToEmpty(unit);\n        if (\"CHAR\".equalsIgnoreCase(trimmed)) {\n            return \"CHAR\";\n        }\n        if (\"BYTE\".equalsIgnoreCase(trimmed)) {\n            return \"BYTE\";\n        }\n        throw new IllegalArgumentException(\"Unsupported VARCHAR unit: \" + unit);\n    }\n\n    public static String requireConstraintType(String constraintType) {\n        String normalized = StringUtils.trimToEmpty(constraintType).toUpperCase(Locale.ROOT);\n        if (CONSTRAINT_TYPES.contains(normalized)) {\n            return normalized;\n        }\n        throw new IllegalArgumentException(\"Unsupported SUNDB constraint type: \" + constraintType);\n    }\n\n    public static String requireNullOrder(String nullOrder) {\n        String normalized = StringUtils.trimToEmpty(nullOrder).toUpperCase(Locale.ROOT);\n        if (normalized.isEmpty()) {\n            return \"\";\n        }\n        if (\"NULLS FIRST\".equals(normalized) || \"NULL FIRST\".equals(normalized)) {\n            return \"NULLS FIRST\";\n        }","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-plugins/chat2db-community-sundb/src/main/java/ai/chat2db/plugin/sundb/SUNDBSqlGuards.java#L78-L114","documentation":"Thrown by SUNDBSqlGuards.requireUnit when a VARCHAR size unit, after trimming, is neither CHAR nor BYTE. SUNDB VARCHAR length semantics accept only those two units; anything else is rejected to prevent injecting tokens into the DDL.","triggerScenarios":"Setting a VARCHAR column's length unit to a value other than CHAR/BYTE - e.g. 'CODEUNITS', 'OCTETS', or a stray string. An empty/null unit also fails.","commonSituations":"Cross-dialect metadata using 'CHARACTER_LENGTH'/'OCTETS'; UI defaulting a unit field to a placeholder; a copy-paste of a full type like 'VARCHAR(10 CHAR)' into the unit field.","solutions":["Set the unit to 'CHAR' or 'BYTE'.","If the column does not need explicit length semantics, omit the unit entirely rather than sending a placeholder.","Map non-SUNDB units (OCTETS->BYTE, CODEUNITS->CHAR) before populating the model."],"exampleFix":"// before\ncol.setLengthUnit(\"OCTETS\");\n// -> Unsupported VARCHAR unit\n\n// after\ncol.setLengthUnit(\"BYTE\");","handlingStrategy":"validation","validationCode":"String u = unit == null ? \"\" : unit.trim();\nif (!\"CHAR\".equalsIgnoreCase(u) && !\"BYTE\".equalsIgnoreCase(u)) {\n    throw new IllegalArgumentException(\"Reject VARCHAR unit: \" + unit);\n}","typeGuard":"static boolean isValidSundbUnit(String u) {\n    return u != null && (\"CHAR\".equalsIgnoreCase(u.trim()) || \"BYTE\".equalsIgnoreCase(u.trim()));\n}","tryCatchPattern":null,"preventionTips":["Use CHAR or BYTE only, or omit the unit.","Map OCTETS->BYTE and CODEUNITS->CHAR when importing.","Validate at the boundary."],"tags":["sundb","ddl","varchar","validation","security"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}