t8y2/dbx · error · IllegalArgumentException
Unsupported object type: " + objectType
Error message
Unsupported object type: " + objectType
What it means
H2Agent.getObjectSource generates an INFORMATION_SCHEMA query based on the object type; only VIEW, FUNCTION, and PROCEDURE are accepted. Other types hit the switch default and throw IllegalArgumentException. On H2 1.x, functions/procedures are read from FUNCTION_ALIASES; on 2.x from ROUTINES.
Source
Thrown at agents/drivers/h2/src/main/java/com/dbx/agent/h2/H2Agent.java:285
while (rs.next()) {
result.add(new ObjectInfo(rs.getString(1), normalizeTableType(rs.getString(2)), schema, null));
}
}
}
return constraints.withoutPaging().filterObjects(result);
});
}
@Override
public ObjectSource getObjectSource(String schema, String name, String objectType) {
return unchecked(() -> {
String effectiveSchema = resolveSchema(schema);
String sql = switch (objectType.toUpperCase(Locale.ROOT)) {
case "VIEW" -> "SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?";
case "FUNCTION", "PROCEDURE" -> isVersion2OrLater()
? "SELECT ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA = ? AND ROUTINE_NAME = ?"
: "SELECT SOURCE FROM INFORMATION_SCHEMA.FUNCTION_ALIASES WHERE ALIAS_SCHEMA = ? AND ALIAS_NAME = ?";
default -> throw new IllegalArgumentException("Unsupported object type: " + objectType);
};
String source = "";
try (var stmt = requireConnected().prepareStatement(sql)) {
stmt.setString(1, effectiveSchema);
stmt.setString(2, name);
try (ResultSet rs = stmt.executeQuery()) {
if (rs.next()) {
String value = rs.getString(1);
source = value == null ? "" : value;
}
}
}
return new ObjectSource(name, objectType, schema, source);
});
}
@OverrideView on GitHub (pinned to c0390bff16)
Solutions
- Pass only VIEW, FUNCTION, or PROCEDURE (case-insensitive)
- Trim the type string before calling
- Use table-specific DDL APIs for tables and other kinds
Example fix
// before
agent.getObjectSource(schema, name, " TABLE ");
// after
String t = objectType.trim().toUpperCase(Locale.ROOT);
if (t.equals("VIEW") || t.equals("FUNCTION") || t.equals("PROCEDURE")) {
agent.getObjectSource(schema, name, objectType.trim());
} else {
throw new IllegalArgumentException("H2 source supports only VIEW/FUNCTION/PROCEDURE");
} Defensive patterns
Strategy: validation
Validate before calling
if (objectType == null) throw new IllegalArgumentException("objectType required"); String t = objectType.trim().toUpperCase(Locale.ROOT); if (!List.of("VIEW","FUNCTION","PROCEDURE").contains(t)) throw new IllegalArgumentException("H2 source supports only VIEW/FUNCTION/PROCEDURE"); Type guard
static boolean isSupportedH2ObjectType(String t) { return t != null && List.of("VIEW","FUNCTION","PROCEDURE").contains(t.trim().toUpperCase(Locale.ROOT)); } Try / catch
try { src = agent.getObjectSource(schema, name, type); } catch (IllegalArgumentException e) { log.warn("Unsupported H2 object type: {}", type); return Optional.empty(); } Prevention
- Normalize and trim object types before calling
- Use table-specific DDL for tables; this API covers views/routines only
- Guard against null types (would NPE before the switch throws)
When it happens
Trigger: Calling getObjectSource with a type like 'TABLE', 'CONSTRAINT', 'DOMAIN', or an untrimmed string; null type would NPE at toUpperCase before the switch.
Common situations: Passing types from other databases' metadata (tables via this API); tooling enumerating all object kinds uniformly; case/whitespace differences in type strings.
Related errors
- Unsupported object type: {objectType}
- Unsupported object type: {objectType}
- Unsupported object type: " + objectType
- Unsupported object type: {objectType}
- Unsupported object type: {objectType}
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/67a95ad09f72c174.
Report an issue: GitHub.