OtterMind/Chat2DB · error · IllegalArgumentException

Invalid Oscar default value: ${defaultValue}

Error message

Invalid Oscar default value: ${defaultValue}

What it means

Error "Invalid Oscar default value: ${defaultValue}" thrown in OtterMind/Chat2DB.

Source

Thrown at chat2db-community-server/chat2db-community-plugins/chat2db-community-oscar/src/main/java/ai/chat2db/plugin/oscar/OscarSqlGuards.java:44

            "NOT", "NULL", "PRIMARY", "REFERENCES", "UNIQUE");
    private static final Set<String> STATEMENT_KEYWORDS = Set.of(
            "ALTER", "CREATE", "DELETE", "DROP", "GRANT", "INSERT", "MERGE",
            "REVOKE", "SELECT", "TRUNCATE", "UPDATE");

    private OscarSqlGuards() {
    }

    /**
     * Validates a raw DEFAULT expression emitted verbatim into DDL (positions where
     * quoting would change semantics). Accepts numeric literals, single-quoted string
     * literals (with '' escapes), plain keywords such as SYSDATE/CURRENT_TIMESTAMP,
     * and simple function calls such as sys_guid() or to_date('2024-01-01','YYYY-MM-DD').
     * Quoted-literal and function-call shapes are recognized with linear-time scanners
     * (no regex), so the check cannot be driven into regex backtracking.
     */
    public static String requireDefaultValueExpression(String defaultValue) {
        if (StringUtils.isBlank(defaultValue)) {
            throw new IllegalArgumentException("Invalid Oscar default value: " + defaultValue);
        }
        String value = defaultValue.trim();
        if (NUMERIC_DEFAULT_PATTERN.matcher(value).matches()
                || KEYWORD_DEFAULT_PATTERN.matcher(value).matches()
                || isQuotedStringLiteral(value)
                || isSimpleFunctionCall(value)) {
            return value;
        }
        throw new IllegalArgumentException("Invalid Oscar default value: " + defaultValue);
    }

    /**
     * True when {@code s} is exactly one single-quoted string literal with '' escapes.
     * Linear scan, no backtracking.
     */
    static boolean isQuotedStringLiteral(String s) {
        return s.length() >= 2 && s.charAt(0) == '\'' && quotedLiteralEnd(s, 0) == s.length();
    }

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Correct the column default value so it is valid for Oscar SQL, or remove the default.

When it happens

Trigger: An Oscar column definition carried a default value that failed validation.

Common situations: See trigger scenarios.


AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14). Data as JSON: /api/errors/bf95989a2710bbef. Report an issue: GitHub.