{"record":{"id":"884751875b85b6e0","repo":"OtterMind/Chat2DB","slug":"invalid-mysql-hex-digits-value","errorCode":null,"errorMessage":"Invalid MySQL hex digits: {value}","messagePattern":"Invalid MySQL hex digits: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"chat2db-community-server/chat2db-community-plugins/chat2db-community-mysql/src/main/java/ai/chat2db/plugin/mysql/MysqlSqlGuards.java","lineNumber":73,"sourceCode":"        return value;\n    }\n\n    /**\n     * Validate content of a b'...' bit literal.\n     */\n    public static String requireBitLiteral(String value) {\n        if (value == null || !BIT_LITERAL_PATTERN.matcher(value).matches()) {\n            throw new IllegalArgumentException(\"Invalid MySQL bit literal: \" + value);\n        }\n        return value;\n    }\n\n    /**\n     * Validate the digits of a 0x... hex literal (the template adds the 0x prefix).\n     */\n    public static String requireHexDigits(String value) {\n        if (value == null || !HEX_DIGITS_PATTERN.matcher(value).matches()) {\n            throw new IllegalArgumentException(\"Invalid MySQL hex digits: \" + value);\n        }\n        return value;\n    }\n\n    /**\n     * True only when the value is a well-formed 0x... hex literal. Values that merely\n     * start with 0x but contain non-hex characters must not pass through into SQL raw.\n     */\n    public static boolean isHexLiteral(String value) {\n        return value != null && HEX_LITERAL_PATTERN.matcher(value).matches();\n    }\n\n    /**\n     * Validate a DEFINER value (user@host, parts optionally single-quoted or backtick-quoted).\n     */\n    public static String requireDefiner(String value) {\n        if (value == null || !DEFINER_PATTERN.matcher(value).matches()) {\n            throw new IllegalArgumentException(\"Invalid MySQL definer: \" + value);","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-plugins/chat2db-community-mysql/src/main/java/ai/chat2db/plugin/mysql/MysqlSqlGuards.java#L55-L91","documentation":"Thrown by MysqlSqlGuards.requireHexDigits when the digits of a 0x... hex literal (without the 0x prefix, which the template adds) fail ^[0-9a-fA-F]+$. Only hexadecimal digits are accepted; null, empty, or non-hex characters are rejected because they would corrupt the literal.","triggerScenarios":"Calling requireHexDigits(value) with a string containing non-hex characters (g-z, symbols), an empty string, or null. The caller passes only the hex digits, not the full 0x... literal.","commonSituations":"Passing the full 0x1A2B literal instead of just '1A2B'; a value containing an odd trailing character from copy-paste; a UI hex input that did not strip a leading '0x'; passing a UUID with dashes to a hex literal position.","solutions":["Pass only the raw hex digits to requireHexDigits, not the 0x-prefixed form.","Strip a leading 0x/0X and validate the remainder matches ^[0-9a-fA-F]+$ before calling.","Remove dashes/colons from formatted hex (UUIDs) before validation.","Reject empty/null hex values upstream."],"exampleFix":"// before\nMysqlSqlGuards.requireHexDigits(rawHex);\n\n// after\nString hex = StringUtils.trimToNull(rawHex);\nif (hex != null && (hex.startsWith(\"0x\") || hex.startsWith(\"0X\"))) {\n    hex = hex.substring(2);\n}\nif (hex == null || !hex.matches(\"^[0-9a-fA-F]+$\")) {\n    throw new IllegalArgumentException(\"Invalid MySQL hex digits: \" + rawHex);\n}\nMysqlSqlGuards.requireHexDigits(hex);","handlingStrategy":"validation","validationCode":"String hex = StringUtils.trimToNull(value);\nif (hex != null && (hex.startsWith(\"0x\") || hex.startsWith(\"0X\"))) {\n    hex = hex.substring(2);\n}\nif (hex == null || !hex.matches(\"^[0-9a-fA-F]+$\")) {\n    throw new IllegalArgumentException(\"Invalid MySQL hex digits: \" + value);\n}\nMysqlSqlGuards.requireHexDigits(hex);","typeGuard":"static boolean isHexDigits(String value) {\n    return value != null && value.matches(\"^[0-9a-fA-F]+$\");\n}","tryCatchPattern":null,"preventionTips":["Pass only the raw hex digits, not the 0x prefix.","Strip a leading 0x/0X before validation.","Remove dashes/colons from formatted hex (UUIDs).","Reject empty/null hex values upstream."],"tags":["mysql","validation","ddl","hex-literal"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}