t8y2/dbx · error · IllegalArgumentException

Unsupported object type: " + objectType

Error message

Unsupported object type: " + objectType

What it means

SqlServerLegacyAgent (SQL Server 2000) maps a normalized object-type name to the legacy sysobjects xtype via sqlServer2000ObjectXtype; the null return means the type has no xtype and therefore no retrievable source, so getObjectSource throws IllegalArgumentException before touching the database.

Source

Thrown at agents/drivers/sqlserver-legacy/src/main/java/com/dbx/agent/sqlserverlegacy/SqlServerLegacyAgent.java:341

        return super.getColumns(metadataSchema(schema, table), table);
    }

    @Override
    public List<IndexInfo> listIndexes(String schema, String table) {
        return super.listIndexes(metadataSchema(schema, table), table);
    }

    @Override
    public List<ForeignKeyInfo> listForeignKeys(String schema, String table) {
        return super.listForeignKeys(metadataSchema(schema, table), table);
    }

    @Override
    public ObjectSource getObjectSource(String schema, String name, String objectType) {
        String normalizedType = objectType == null ? "" : objectType.trim().toUpperCase(Locale.ROOT);
        String objectXtype = sqlServer2000ObjectXtype(normalizedType);
        if (objectXtype == null) {
            throw new IllegalArgumentException("Unsupported object type: " + objectType);
        }
        return unchecked(() -> {
            String resolvedSchema = metadataSchema(schema, name);
            StringBuilder source = new StringBuilder();
            try (PreparedStatement statement = requireConnection().prepareStatement(sqlServer2000ObjectSourceSql())) {
                statement.setString(1, resolvedSchema);
                statement.setString(2, name);
                statement.setString(3, objectXtype);
                try (ResultSet resultSet = statement.executeQuery()) {
                    while (resultSet.next()) {
                        String chunk = resultSet.getString("source_text");
                        if (chunk != null) {
                            source.append(chunk);
                        }
                    }
                }
            }
            // SQL Server 2000 exposes syscomments as source chunks. The legacy

View on GitHub (pinned to c0390bff16)

Solutions

  1. Only request source for types that map to an xtype (e.g. VIEW, PROCEDURE, FUNCTION, TRIGGER, TABLE-backed objects); skip others in the caller.
  2. Normalize the type first: trim, uppercase (Locale.ROOT) before calling — the agent normalizes but a null/unknown name still fails.
  3. If Oracle-style types must appear in the UI, hide or disable 'view source' for types unsupported on SQL Server 2000.

Example fix

// before
var src = agent.getObjectSource(schema, name, "MATERIALIZED_VIEW"); // throws on SQL 2000
// after
String xtype = type == null ? null : type.trim().toUpperCase(Locale.ROOT);
if ("VIEW".equals(xtype) || "PROCEDURE".equals(xtype) || "FUNCTION".equals(xtype) || "TRIGGER".equals(xtype)) {
    var src = agent.getObjectSource(schema, name, xtype);
}
Defensive patterns

Strategy: type-guard

Validate before calling

String t = objectType == null ? "" : objectType.trim().toUpperCase(Locale.ROOT);
if (Set.of("VIEW","PROCEDURE","FUNCTION","TRIGGER","TABLE","INDEX","DEFAULT","RULE").indexOf(t) < 0) {
    // xtype mapping would fail; skip
}

Type guard

boolean sql2000HasXtype(String t) {
    if (t == null) return false;
    switch (t.trim().toUpperCase(Locale.ROOT)) {
        case "VIEW": case "PROCEDURE": case "FUNCTION": case "TRIGGER":
        case "TABLE": case "INDEX": case "DEFAULT": case "RULE":
            return true;
        default:
            return false;
    }
}

Try / catch

try {
    source = agent.getObjectSource(schema, name, type);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Unsupported object type")) {
        source = ""; // SQL Server 2000 keeps no source for this kind
    } else throw e;
}

Prevention

When it happens

Trigger: Calling getObjectSource with a type that doesn't map to a SQL Server 2000 xtype — e.g. "MATERIALIZED_VIEW" (SQL Server 2000 has no indexed/materialized views exposed this way), "SEQUENCE", "PACKAGE", or any misspelled/unnormalized string.

Common situations: Shared UI code written for Oracle-style drivers sends Oracle-only types like PACKAGE to SQL Server 2000; a generic explorer requests source for every catalog row including constraints and indexes; types arrive untrimmed/lowercase from user input.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/08396cc6bdad9871. Report an issue: GitHub.