OtterMind/Chat2DB · error · IllegalArgumentException
Invalid Snowflake {what}: {value}
Error message
Invalid Snowflake {what}: {value} What it means
Thrown by SnowflakeSqlGuards.requireSnowflakeName when the value is null or does not match the pattern ^[A-Za-z0-9_$]+$. This validates strict name tokens used in positions where identifier quoting is impossible by design (ENGINE, CHARACTER SET, COLLATE). Only unquoted alphanumeric, underscore, and dollar-sign characters are accepted. The 'what' parameter labels which name type failed (e.g., engine, character set, collation).
Source
Thrown at chat2db-community-server/chat2db-community-plugins/chat2db-community-snowflake/src/main/java/ai/chat2db/plugin/snowflake/SnowflakeSqlGuards.java:40
"GRANT", "INSERT", "MERGE", "PRIMARY", "REFERENCES", "REVOKE", "TRUNCATE", "UNIQUE",
"UPDATE", "SELECT");
private static final Set<String> TYPE_BREAKOUT_KEYWORDS = Set.of(
"CHECK", "COLLATE", "CONSTRAINT", "DEFAULT", "GENERATED", "NOT", "NULL", "PRIMARY",
"REFERENCES", "UNIQUE");
private static final Set<String> CLAUSE_BREAKOUT_KEYWORDS = Set.of(
"ALTER", "CALL", "COPY", "CREATE", "DELETE", "DROP", "GRANT", "INSERT", "MERGE",
"REVOKE", "TRUNCATE", "UPDATE", "USE");
private SnowflakeSqlGuards() {
}
/**
* Validate a strict Snowflake name token (ENGINE / CHARACTER SET / COLLATE style positions where
* escaping is impossible by design).
*/
public static String requireSnowflakeName(String value, String what) {
if (value == null || !SNOWFLAKE_NAME_PATTERN.matcher(value).matches()) {
throw new IllegalArgumentException("Invalid Snowflake " + what + ": " + value);
}
return value;
}
/**
* Validate a quote-aware DEFAULT expression. Quoted literal content is normalized without
* double-escaping existing doubled quotes. Other expressions may contain nested calls and
* Snowflake sequence references, but cannot terminate the statement or append a constraint.
*/
public static String requireDefaultExpression(String value) {
if (StringUtils.isBlank(value)) {
throw invalid("default value", value);
}
String trimmed = value.trim();
if (trimmed.length() >= 2 && trimmed.startsWith("'") && trimmed.endsWith("'")) {
return "'" + normalizeStringLiteralContent(trimmed.substring(1, trimmed.length() - 1)) + "'";
}
scanExpression(trimmed, DEFAULT_BREAKOUT_KEYWORDS, false, "default value");View on GitHub (pinned to 5ee1e990e7)
Solutions
- Sanitize the name to contain only [A-Za-z0-9_$] characters before calling requireSnowflakeName
- Quote the identifier at the SQL construction level instead of passing it through this strict guard
- Validate user input against the same pattern before submitting DDL
Example fix
// before
SnowflakeSqlGuards.requireSnowflakeName("my engine", "engine");
// after
String name = "my_engine"; // sanitize: replace spaces/special chars with underscore
SnowflakeSqlGuards.requireSnowflakeName(name, "engine"); Defensive patterns
Strategy: validation
Validate before calling
private static final Pattern SNOWFLAKE_NAME = Pattern.compile("^[A-Za-z0-9_$]+$");
public static String sanitizeSnowflakeName(String value) {
if (value == null || !SNOWFLAKE_NAME.matcher(value).matches()) {
String sanitized = value == null ? "" : value.replaceAll("[^A-Za-z0-9_$]", "_");
return sanitized.isEmpty() ? null : sanitized;
}
return value;
} Type guard
public static boolean isValidSnowflakeName(String value) {
return value != null && !value.isEmpty()
&& value.chars().allMatch(c -> Character.isLetterOrDigit(c) || c == '_' || c == '$');
} Prevention
- Validate names against ^[A-Za-z0-9_$]+$ before passing to requireSnowflakeName
- Replace spaces and special characters with underscores as a sanitization step
- Use quoted identifiers at the SQL level instead of strict guards for names that need special characters
When it happens
Trigger: Calling SnowflakeSqlGuards.requireSnowflakeName(value, what) where value is null, empty, or contains characters outside [A-Za-z0-9_$]. This includes spaces, hyphens, dots, special characters, and non-ASCII characters.
Common situations: A column or table metadata field containing a space or special character in an engine/charset/collation position; a user-entered default value referencing an object name with invalid characters; metadata imported from a system that allows characters Snowflake rejects in unquoted positions.
Related errors
- Invalid Hive {what}: {value}
- Invalid Snowflake index sort direction: {value}
- Snowflake index requires at least one named column
- Invalid DB2 index column ordering: {ascOrDesc}
- Unsupported DM VARCHAR unit: {unit}
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/30b6dec23857d7f8.
Report an issue: GitHub.