{"record":{"id":"4d61ea0efe21d448","repo":"t8y2/dbx","slug":"unsupported-object-type-objecttype-4d61ea","errorCode":null,"errorMessage":"Unsupported object type: {objectType}","messagePattern":"Unsupported object type: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"agents/drivers/dameng/src/main/java/com/dbx/agent/dameng/DamengAgent.java","lineNumber":1330,"sourceCode":"                }\n            }\n            case \"SEQUENCE\" -> {\n                ObjectSource fromSequence = catalogSequenceSource(schema, name, objectType);\n                if (fromSequence != null) {\n                    return fromSequence;\n                }\n            }\n            case \"PROCEDURE\", \"FUNCTION\", \"PACKAGE\", \"PACKAGE_BODY\", \"TYPE\", \"TYPE_BODY\" -> {\n                ObjectSource fromAllSource = catalogRoutineSource(schema, name, objectType);\n                if (fromAllSource != null) {\n                    return fromAllSource;\n                }\n                ObjectSource fromSystemText = catalogRoutineSystemText(schema, name, objectType);\n                if (fromSystemText != null) {\n                    return fromSystemText;\n                }\n            }\n            default -> throw new IllegalArgumentException(\"Unsupported object type: \" + objectType);\n        }\n        return unavailableObjectSource(schema, name, objectType, dbmsError);\n    }\n\n    /**\n     * 字典视图来源（ALL_VIEWS.TEXT / ALL_TRIGGERS.TRIGGER_BODY）通常只包含对象正文、\n     * 不含完整的 CREATE/ALTER 语句头，不能作为可执行 DDL 保存，故标记为不可在线编辑。\n     */\n    private static final String CATALOG_BODY_HINT =\n        \"-- 以下内容来自系统字典视图，仅为对象正文，可能不包含完整语句头，不可在线编辑。\\n\";\n\n    /** 读取单行单列文本（视图/触发器源码），空结果返回空串。 */\n    private String scalarText(String sql, String schema, String name) throws Exception {\n        try (PreparedStatement stmt = requireConnected().prepareStatement(sql)) {\n            stmt.setString(1, schema);\n            stmt.setString(2, name);\n            try (ResultSet rs = stmt.executeQuery()) {\n                return rs.next() ? coalesce(readTextColumn(rs, 1)) : \"\";","sourceCodeStart":1312,"sourceCodeEnd":1348,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/dameng/src/main/java/com/dbx/agent/dameng/DamengAgent.java#L1312-L1348","documentation":"DamengAgent's object-source lookup switch handles VIEW, MATERIALIZED_VIEW, TRIGGER, SEQUENCE, and routine types (PROCEDURE, FUNCTION, PACKAGE, PACKAGE_BODY, TYPE, TYPE_BODY); any other objectType hits the default branch and throws IllegalArgumentException. The agent only implements source retrieval for object kinds it can read from DM dictionary views or DBMS_METADATA.","triggerScenarios":"Requesting source for an object type not in the handled set — e.g. INDEX, SYNONYM, USER, TABLESPACE, DBLINK — via getObjectSource/getObjectDdl, or passing a type string that doesn't normalize (trim/uppercase/spaces-to-underscores) to one of the known keys.","commonSituations":"Generic schema-browser code enumerating every object type from metadata and asking for source on each; type names obtained from a different database's metadata (e.g. Oracle's 'DATABASE LINK') fed directly into the Dameng agent; whitespace/case variants that normalize to unknown keys.","solutions":["Restrict source-retrieval calls to supported types: VIEW, MATERIALIZED_VIEW, TRIGGER, SEQUENCE, PROCEDURE, FUNCTION, PACKAGE, PACKAGE_BODY, TYPE, TYPE_BODY.","Normalize the type before calling: trim, uppercase, replace spaces with underscores (mirroring normalizeObjectSourceType).","For unsupported types, use getTableDdl for tables or skip source retrieval and mark the object as 'source unavailable'.","Wrap in try-catch (IllegalArgumentException) and degrade gracefully in UI/tooling.","If a type is genuinely needed, extend the switch in DamengAgent with a dictionary query for that kind."],"exampleFix":"// before\nObjectSource src = damengAgent.getObjectSource(schema, \"MY_INDEX\", \"INDEX\"); // throws\n// after\nString normalized = objectType == null ? \"\" : objectType.trim().toUpperCase(Locale.ROOT).replace(' ', '_');\nSet<String> supported = Set.of(\"VIEW\",\"MATERIALIZED_VIEW\",\"TRIGGER\",\"SEQUENCE\",\"PROCEDURE\",\"FUNCTION\",\"PACKAGE\",\"PACKAGE_BODY\",\"TYPE\",\"TYPE_BODY\");\nObjectSource src = supported.contains(normalized)\n    ? damengAgent.getObjectSource(schema, name, objectType)\n    : ObjectSource.unavailable(schema, name, objectType, \"source not supported for \" + normalized);","handlingStrategy":"validation","validationCode":"String normalized = objectType == null ? \"\" : objectType.trim().toUpperCase(Locale.ROOT).replace(' ', '_');\nSet<String> supported = Set.of(\"VIEW\",\"MATERIALIZED_VIEW\",\"TRIGGER\",\"SEQUENCE\",\"PROCEDURE\",\"FUNCTION\",\"PACKAGE\",\"PACKAGE_BODY\",\"TYPE\",\"TYPE_BODY\");\nif (!supported.contains(normalized)) { /* skip or use unavailable-source placeholder */ }","typeGuard":"static boolean isDamengSourceableType(String objectType) {\n    if (objectType == null) return false;\n    String t = objectType.trim().toUpperCase(Locale.ROOT).replace(' ', '_');\n    return Set.of(\"VIEW\",\"MATERIALIZED_VIEW\",\"TRIGGER\",\"SEQUENCE\",\"PROCEDURE\",\"FUNCTION\",\"PACKAGE\",\"PACKAGE_BODY\",\"TYPE\",\"TYPE_BODY\").contains(t);\n}","tryCatchPattern":"try {\n    ObjectSource src = damengAgent.getObjectSource(schema, name, objectType);\n} catch (IllegalArgumentException e) {\n    ObjectSource src = ObjectSource.unavailable(schema, name, objectType, \"Dameng source not available for this type\");\n}","preventionTips":["Normalize type strings (trim, uppercase, spaces to underscores) before calling","Only request source for the ten types DamengAgent implements","Skip source retrieval for INDEX/SYNONYM/USER-style objects and mark them unavailable","Catch IllegalArgumentException in schema-wide metadata sweeps"],"tags":["unsupported-object-type","dameng","illegal-argument","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-14T05:17:10.506Z"}