{"record":{"id":"08396cc6bdad9871","repo":"t8y2/dbx","slug":"unsupported-object-type-objecttype-08396c","errorCode":null,"errorMessage":"Unsupported object type: \" + objectType","messagePattern":"Unsupported object type: \" \\+ objectType","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"agents/drivers/sqlserver-legacy/src/main/java/com/dbx/agent/sqlserverlegacy/SqlServerLegacyAgent.java","lineNumber":341,"sourceCode":"        return super.getColumns(metadataSchema(schema, table), table);\n    }\n\n    @Override\n    public List<IndexInfo> listIndexes(String schema, String table) {\n        return super.listIndexes(metadataSchema(schema, table), table);\n    }\n\n    @Override\n    public List<ForeignKeyInfo> listForeignKeys(String schema, String table) {\n        return super.listForeignKeys(metadataSchema(schema, table), table);\n    }\n\n    @Override\n    public ObjectSource getObjectSource(String schema, String name, String objectType) {\n        String normalizedType = objectType == null ? \"\" : objectType.trim().toUpperCase(Locale.ROOT);\n        String objectXtype = sqlServer2000ObjectXtype(normalizedType);\n        if (objectXtype == null) {\n            throw new IllegalArgumentException(\"Unsupported object type: \" + objectType);\n        }\n        return unchecked(() -> {\n            String resolvedSchema = metadataSchema(schema, name);\n            StringBuilder source = new StringBuilder();\n            try (PreparedStatement statement = requireConnection().prepareStatement(sqlServer2000ObjectSourceSql())) {\n                statement.setString(1, resolvedSchema);\n                statement.setString(2, name);\n                statement.setString(3, objectXtype);\n                try (ResultSet resultSet = statement.executeQuery()) {\n                    while (resultSet.next()) {\n                        String chunk = resultSet.getString(\"source_text\");\n                        if (chunk != null) {\n                            source.append(chunk);\n                        }\n                    }\n                }\n            }\n            // SQL Server 2000 exposes syscomments as source chunks. The legacy","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/sqlserver-legacy/src/main/java/com/dbx/agent/sqlserverlegacy/SqlServerLegacyAgent.java#L323-L359","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Only request source for types that map to an xtype (e.g. VIEW, PROCEDURE, FUNCTION, TRIGGER, TABLE-backed objects); skip others in the caller.","Normalize the type first: trim, uppercase (Locale.ROOT) before calling — the agent normalizes but a null/unknown name still fails.","If Oracle-style types must appear in the UI, hide or disable 'view source' for types unsupported on SQL Server 2000."],"exampleFix":"// before\nvar src = agent.getObjectSource(schema, name, \"MATERIALIZED_VIEW\"); // throws on SQL 2000\n// after\nString xtype = type == null ? null : type.trim().toUpperCase(Locale.ROOT);\nif (\"VIEW\".equals(xtype) || \"PROCEDURE\".equals(xtype) || \"FUNCTION\".equals(xtype) || \"TRIGGER\".equals(xtype)) {\n    var src = agent.getObjectSource(schema, name, xtype);\n}","handlingStrategy":"type-guard","validationCode":"String t = objectType == null ? \"\" : objectType.trim().toUpperCase(Locale.ROOT);\nif (Set.of(\"VIEW\",\"PROCEDURE\",\"FUNCTION\",\"TRIGGER\",\"TABLE\",\"INDEX\",\"DEFAULT\",\"RULE\").indexOf(t) < 0) {\n    // xtype mapping would fail; skip\n}","typeGuard":"boolean sql2000HasXtype(String t) {\n    if (t == null) return false;\n    switch (t.trim().toUpperCase(Locale.ROOT)) {\n        case \"VIEW\": case \"PROCEDURE\": case \"FUNCTION\": case \"TRIGGER\":\n        case \"TABLE\": case \"INDEX\": case \"DEFAULT\": case \"RULE\":\n            return true;\n        default:\n            return false;\n    }\n}","tryCatchPattern":"try {\n    source = agent.getObjectSource(schema, name, type);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Unsupported object type\")) {\n        source = \"\"; // SQL Server 2000 keeps no source for this kind\n    } else throw e;\n}","preventionTips":["Do not reuse Oracle-style type labels (PACKAGE, SEQUENCE, MATERIALIZED_VIEW) against SQL Server 2000.","Normalize the type (trim/uppercase) before calling.","Disable source viewing for object kinds absent from sysobjects.xtype."],"tags":["sqlserver","sql-server-2000","legacy","unsupported-type"],"backgroundTag":"unsupported-object-type","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}