{"record":{"id":"50e953a5d5986fd2","repo":"OtterMind/Chat2DB","slug":"unsupported-sundb-constraint-type-constrainttype","errorCode":null,"errorMessage":"Unsupported SUNDB constraint type: {constraintType}","messagePattern":"Unsupported SUNDB constraint type: (.+?)","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":104,"sourceCode":"     * 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        }\n        if (\"NULLS LAST\".equals(normalized) || \"NULL LAST\".equals(normalized)) {\n            return \"NULLS LAST\";\n        }\n        throw new IllegalArgumentException(\"Unsupported SUNDB index null ordering: \" + nullOrder);\n    }\n\n    private static void scanExpression(String expression, boolean typeExpression, String description) {\n        Deque<Character> parentheses = new ArrayDeque<>();","sourceCodeStart":86,"sourceCodeEnd":122,"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#L86-L122","documentation":"Thrown by SUNDBSqlGuards.requireConstraintType when a constraint type, upper-cased and trimmed, is not in {CHECK, FOREIGN KEY, PRIMARY KEY, UNIQUE}. The validator whitelists only these constraint kinds before emitting DDL.","triggerScenarios":"Passing a constraint type string outside the allowed set - e.g. 'NOT NULL', 'DEFAULT', 'INDEX', or a free-text label.","commonSituations":"Confusing column-level NOT NULL/DEFAULT (not constraint types here) with table-level constraint kinds; cross-dialect metadata naming differences; UI label passed instead of the canonical value.","solutions":["Use one of CHECK, FOREIGN KEY, PRIMARY KEY, or UNIQUE (case-insensitive).","Handle NOT NULL / DEFAULT as column attributes, not as constraint types.","Normalize/validate the constraint type against the allowed set before DDL generation."],"exampleFix":"// before\nconstraint.setType(\"NOT NULL\");\n// -> Unsupported SUNDB constraint type\n\n// after\nconstraint.setType(\"CHECK\");","handlingStrategy":"validation","validationCode":"Set<String> OK = Set.of(\"CHECK\", \"FOREIGN KEY\", \"PRIMARY KEY\", \"UNIQUE\");\nif (!OK.contains(StringUtils.trimToEmpty(constraintType).toUpperCase(Locale.ROOT))) {\n    throw new IllegalArgumentException(\"Reject SUNDB constraint type: \" + constraintType);\n}","typeGuard":"static boolean isValidSundbConstraintType(String t) {\n    return t != null && Set.of(\"CHECK\", \"FOREIGN KEY\", \"PRIMARY KEY\", \"UNIQUE\")\n        .contains(t.trim().toUpperCase(Locale.ROOT));\n}","tryCatchPattern":null,"preventionTips":["Use only CHECK, FOREIGN KEY, PRIMARY KEY, UNIQUE.","Handle NOT NULL/DEFAULT as column attributes, not constraint types.","Validate at the boundary."],"tags":["sundb","ddl","constraint","validation"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}