{"record":{"id":"9788826d8c5a2d68","repo":"OtterMind/Chat2DB","slug":"invalid-sundb-index-sort-direction-value","errorCode":null,"errorMessage":"Invalid SUNDB index sort direction: {value}","messagePattern":"Invalid SUNDB index sort direction: (.+?)","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":52,"sourceCode":"            List.of(\"DAY\", \"TO\", \"SECOND\"), List.of(\"HOUR\", \"TO\", \"MINUTE\"),\n            List.of(\"HOUR\", \"TO\", \"SECOND\"), List.of(\"MINUTE\", \"TO\", \"SECOND\"));\n\n    private SUNDBSqlGuards() {\n    }\n\n    /**\n     * Validates an index sort direction: only ASC/DESC are legal, returned in\n     * canonical uppercase. Anything else is rejected to block DDL injection.\n     */\n    public static String requireAscOrDesc(String value) {\n        String trimmed = value == null ? \"\" : value.trim();\n        if (\"ASC\".equalsIgnoreCase(trimmed)) {\n            return \"ASC\";\n        }\n        if (\"DESC\".equalsIgnoreCase(trimmed)) {\n            return \"DESC\";\n        }\n        throw new IllegalArgumentException(\"Invalid SUNDB index sort direction: \" + value);\n    }\n\n    /**\n     * Validates one complete DEFAULT expression. Nested calls, sequence\n     * expressions, operators, and quoted literals remain available while\n     * statement terminators, comments, unbalanced delimiters, top-level commas,\n     * and trailing column clauses are rejected.\n     */\n    public static String requireDefaultValue(String defaultValue) {\n        String trimmed = StringUtils.trimToNull(defaultValue);\n        if (trimmed == null) {\n            throw invalid(\"DEFAULT expression\", defaultValue);\n        }\n        scanExpression(trimmed, false, \"DEFAULT expression\");\n        return trimmed;\n    }\n\n    /**","sourceCodeStart":34,"sourceCodeEnd":70,"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#L34-L70","documentation":"Thrown by SUNDBSqlGuards.requireAscOrDesc when an index sort direction, after trimming, is neither ASC nor DESC. The validator canonicalizes to uppercase ASC/DESC and rejects anything else to block DDL injection.","triggerScenarios":"Passing a non-null, non-blank sort-direction value that is not ASC or DESC (e.g. 'NULLS FIRST', 'A', a localized word). A null/blank input is normalized to '' and also fails.","commonSituations":"Metadata/UI supplying a placeholder or a direction SUNDB does not support per index column; cross-dialect import carrying NULLS ordering.","solutions":["Pass only 'ASC' or 'DESC' (case-insensitive).","Leave the direction unset/null at the source if SUNDB should use its default, but ensure the caller does not forward a blank to requireAscOrDesc.","Normalize imported metadata to ASC/DESC before building the index."],"exampleFix":"// before\ncol.setAscOrDesc(\"NULLS FIRST\");\n// -> Invalid SUNDB index sort direction\n\n// after\ncol.setAscOrDesc(\"ASC\");","handlingStrategy":"validation","validationCode":"String v = value == null ? \"\" : value.trim();\nif (!\"ASC\".equalsIgnoreCase(v) && !\"DESC\".equalsIgnoreCase(v)) {\n    throw new IllegalArgumentException(\"Reject SUNDB sort direction: \" + value);\n}","typeGuard":"static boolean isValidSundbAscOrDesc(String v) {\n    return v != null && (\"ASC\".equalsIgnoreCase(v.trim()) || \"DESC\".equalsIgnoreCase(v.trim()));\n}","tryCatchPattern":null,"preventionTips":["Pass only ASC/DESC.","Do not forward NULLS ordering into the per-column direction field.","Validate at the boundary."],"tags":["sundb","ddl","index","validation","security"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}