{"record":{"id":"74c962f19ab88b17","repo":"OtterMind/Chat2DB","slug":"invalid-hive-what-value","errorCode":null,"errorMessage":"Invalid Hive {what}: {value}","messagePattern":"Invalid Hive (.+?): (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"chat2db-community-server/chat2db-community-plugins/chat2db-community-hive/src/main/java/ai/chat2db/plugin/hive/HiveSqlGuards.java","lineNumber":41,"sourceCode":"            \"^([+-]?(\\\\d+(\\\\.\\\\d+)?|\\\\.\\\\d+)([eE][+-]?\\\\d+)?|0[xX][0-9a-fA-F]+|(?i:TRUE|FALSE))$\");\n    private static final Set<String> TYPE_BREAKOUT_KEYWORDS = Set.of(\n            \"ALTER\", \"CHECK\", \"CONSTRAINT\", \"CREATE\", \"DEFAULT\", \"DELETE\", \"DROP\", \"GENERATED\",\n            \"GRANT\", \"INSERT\", \"NOT\", \"NULL\", \"PRIMARY\", \"REFERENCES\", \"REVOKE\", \"TRUNCATE\",\n            \"UNIQUE\", \"UPDATE\");\n    private static final Set<String> MULTI_WORD_TYPES = Set.of(\n            \"CHARACTER VARYING\", \"DOUBLE PRECISION\", \"TIME WITH LOCAL TIME ZONE\", \"TIME WITH TIME ZONE\",\n            \"TIMESTAMP WITH LOCAL TIME ZONE\", \"TIMESTAMP WITH TIME ZONE\");\n\n    private HiveSqlGuards() {\n    }\n\n    /**\n     * Validate a strict Hive name token (ENGINE / CHARACTER SET / COLLATE style positions where\n     * escaping is impossible by design).\n     */\n    public static String requireHiveName(String value, String what) {\n        if (value == null || !HIVE_NAME_PATTERN.matcher(value).matches()) {\n            throw new IllegalArgumentException(\"Invalid Hive \" + what + \": \" + value);\n        }\n        return value;\n    }\n\n    /**\n     * Validate a raw DEFAULT literal for numeric-ish columns (positions where quoting would change\n     * semantics). Accepts decimal/scientific numbers, hex literals, TRUE/FALSE.\n     */\n    public static String requireNumericDefault(String value) {\n        if (value == null || !NUMERIC_DEFAULT_PATTERN.matcher(value.trim()).matches()) {\n            throw new IllegalArgumentException(\"Invalid Hive default value: \" + value);\n        }\n        return value;\n    }\n\n    /**\n     * Validate a Hive type expression, including nested ARRAY, MAP, STRUCT, and UNIONTYPE forms.\n     */","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-plugins/chat2db-community-hive/src/main/java/ai/chat2db/plugin/hive/HiveSqlGuards.java#L23-L59","documentation":"Thrown by HiveSqlGuards.requireHiveName when a name (engine, character set, collate, etc.) fails the HIVE_NAME_PATTERN allow-list. Hive exposes these as bare, non-escapable tokens in DDL, so they are restricted to a safe character set rather than escaped. Null or any non-matching value is rejected.","triggerScenarios":"Calling requireHiveName(value, what) for table.getEngine(), a character set, or a collation whose value contains characters outside the allowed Hive name pattern. Reached from HiveSqlBuilder when building CREATE TABLE ... ENGINE .../CHARACTER SET/COLLATE clauses.","commonSituations":"A Hive engine/serde name with a hyphen, space, or path separator; a collation copied from another DB; a manually typed engine name in the table form.","solutions":["Use a plain Hive-legal name (letters/digits/underscore) for engine/charset/collate fields.","If the value is user-entered, validate it against HIVE_NAME_PATTERN before building the DDL.","Leave the field blank when it is not required rather than passing a placeholder."],"exampleFix":"// before\ntable.setEngine(\"org.apache.hadoop.hive.ql.io.OrcInputFormat\"); // dots/spaces fail\nHiveSqlGuards.requireHiveName(table.getEngine(), \"engine\");\n\n// after\ntable.setEngine(\"orc\"); // bare Hive engine/storage token\nHiveSqlGuards.requireHiveName(table.getEngine(), \"engine\");","handlingStrategy":"validation","validationCode":"// HIVE_NAME_PATTERN is not public; mirror its intent with an equivalent check\nprivate static final java.util.regex.Pattern HIVE_NAME =\n    java.util.regex.Pattern.compile(\"^[A-Za-z_][A-Za-z0-9_]*$\");\nstatic boolean isSafeHiveName(String v) {\n    return v != null && HIVE_NAME.matcher(v).matches();\n}","typeGuard":"static String hiveNameOrNull(String v) {\n    return (v != null && HIVE_NAME.matcher(v).matches()) ? v : null;\n}","tryCatchPattern":null,"preventionTips":["Use bare Hive-legal tokens for engine/charset/collate fields.","Leave those fields blank when not required.","Validate user-entered Hive names client-side before DDL generation."],"tags":["hive","sql-guard","ddl","identifier","validation"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}