{"record":{"id":"2b102643db3929ce","repo":"t8y2/dbx","slug":"unsupported-object-type-objecttype","errorCode":null,"errorMessage":"Unsupported object type: {objectType}","messagePattern":"Unsupported object type: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"agents/common/src/main/java/com/dbx/agent/PostgresLikeAgent.java","lineNumber":368,"sourceCode":"            String upperType = objectType.toUpperCase();\n            String sql;\n            if (\"VIEW\".equals(upperType) || \"MATERIALIZED VIEW\".equals(upperType)) {\n                sql = \"SELECT \" + profile.catalogPrefixedFunction(\"get_viewdef\") + \"(\" +\n                    profile.catalogBuiltinFunction(\"to_regclass\") + \"(?), true)\";\n            } else if (\"FUNCTION\".equals(upperType)) {\n                sql = \"SELECT \" + profile.catalogPrefixedFunction(\"get_functiondef\") + \"(p.oid)\\n\" +\n                    \"FROM \" + profile.catalogRelation(\"proc\") + \" p JOIN \" +\n                    profile.catalogRelation(\"namespace\") + \" n ON n.oid = p.pronamespace\\n\" +\n                    \"WHERE n.nspname = ? AND p.proname = ? AND p.prokind = 'f'\\n\" +\n                    \"ORDER BY p.oid LIMIT 1\";\n            } else if (\"PROCEDURE\".equals(upperType)) {\n                sql = \"SELECT \" + profile.catalogPrefixedFunction(\"get_functiondef\") + \"(p.oid)\\n\" +\n                    \"FROM \" + profile.catalogRelation(\"proc\") + \" p JOIN \" +\n                    profile.catalogRelation(\"namespace\") + \" n ON n.oid = p.pronamespace\\n\" +\n                    \"WHERE n.nspname = ? AND p.proname = ? AND p.prokind = 'p'\\n\" +\n                    \"ORDER BY p.oid LIMIT 1\";\n            } else {\n                throw new IllegalArgumentException(\"Unsupported object type: \" + objectType);\n            }\n\n            String source;\n            if (\"VIEW\".equals(upperType) || \"MATERIALIZED VIEW\".equals(upperType)) {\n                try (java.sql.PreparedStatement stmt = requireConnection().prepareStatement(sql)) {\n                    stmt.setString(1, quoteQualifiedIdentifier(schema, name));\n                    try (ResultSet rs = stmt.executeQuery()) {\n                        source = rs.next() ? coalesce(rs.getString(1)) : \"\";\n                    }\n                }\n            } else {\n                try (java.sql.PreparedStatement stmt = requireConnection().prepareStatement(sql)) {\n                    stmt.setString(1, schema);\n                    stmt.setString(2, name);\n                    try (ResultSet rs = stmt.executeQuery()) {\n                        source = rs.next() ? coalesce(rs.getString(1)) : \"\";\n                    }\n                }","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/common/src/main/java/com/dbx/agent/PostgresLikeAgent.java#L350-L386","documentation":"PostgresLikeAgent.getObjectSource() builds catalog queries only for VIEW, MATERIALIZED VIEW, FUNCTION and PROCEDURE. Any other objectType string falls into the final else branch and throws IllegalArgumentException. The agent intentionally fails fast rather than returning an empty source, because it has no catalog query for that object kind.","triggerScenarios":"Calling getObjectSource(schema, name, objectType) with any type other than VIEW, MATERIALIZED VIEW, FUNCTION, or PROCEDURE — e.g. TABLE, SEQUENCE, TRIGGER, INDEX, TYPE, or a lowercase/mispelled variant like 'table' handled correctly only if it maps to a supported type (case is uppercased, but e.g. 'MATERIALIZED_VIEW' with underscore is NOT accepted).","commonSituations":"UI metadata refreshers iterating over all object kinds in a schema and requesting source for each; generic tooling that assumes getObjectSource supports every object type; passing PostgreSQL-specific type names like 'FOREIGN TABLE' or underscore-normalized 'MATERIALIZED_VIEW' that this agent does not handle.","solutions":["Only call getObjectSource for VIEW, MATERIALIZED VIEW, FUNCTION, or PROCEDURE; fetch DDL for other object types via a different API (e.g. getTableDdl or column/metadata APIs).","Normalize the type string before calling: trim, uppercase, and use a space in 'MATERIALIZED VIEW' (not 'MATERIALIZED_VIEW').","Wrap the call in try-catch for IllegalArgumentException and fall back to a 'source unavailable' representation for unsupported types.","If a new type is genuinely needed, extend PostgresLikeAgent.getObjectSource with a catalog query for that type (or override it in the concrete agent subclass)."],"exampleFix":"// before\nObjectSource src = agent.getObjectSource(schema, \"my_seq\", \"SEQUENCE\"); // throws\n// after\nString upper = objectType == null ? \"\" : objectType.trim().toUpperCase();\nif (Set.of(\"VIEW\", \"MATERIALIZED VIEW\", \"FUNCTION\", \"PROCEDURE\").contains(upper)) {\n    ObjectSource src = agent.getObjectSource(schema, name, objectType);\n} else {\n    ObjectSource src = ObjectSource.unavailable(schema, name, objectType, \"source not supported for \" + upper);\n}","handlingStrategy":"validation","validationCode":"private static final Set<String> SUPPORTED = Set.of(\"VIEW\", \"MATERIALIZED VIEW\", \"FUNCTION\", \"PROCEDURE\");\nboolean supported = objectType != null && SUPPORTED.contains(objectType.trim().toUpperCase());\nif (!supported) { /* use alternative DDL API or skip */ }","typeGuard":"static boolean hasObjectSourceSupport(String objectType) {\n    if (objectType == null) return false;\n    String t = objectType.trim().toUpperCase(Locale.ROOT);\n    return t.equals(\"VIEW\") || t.equals(\"MATERIALIZED VIEW\") || t.equals(\"FUNCTION\") || t.equals(\"PROCEDURE\");\n}","tryCatchPattern":"try {\n    ObjectSource src = agent.getObjectSource(schema, name, objectType);\n} catch (IllegalArgumentException e) {\n    ObjectSource src = ObjectSource.unavailable(schema, name, objectType, \"source not supported: \" + e.getMessage());\n}","preventionTips":["Check the agent's supported type list before calling getObjectSource","Normalize type strings (trim/uppercase, space not underscore for 'MATERIALIZED VIEW')","Route TABLE/SEQUENCE/TRIGGER requests to dedicated DDL or metadata APIs","Handle unknown types gracefully in schema-browser loops instead of assuming full coverage"],"tags":["unsupported-object-type","illegal-argument","postgres","catalog-metadata"],"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-14T00:17:10.932Z"}