t8y2/dbx · warning · IllegalArgumentException

Unsupported object type: {objectType}

Error message

Unsupported object type: {objectType}

What it means

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.

Source

Thrown at agents/drivers/dameng/src/main/java/com/dbx/agent/dameng/DamengAgent.java:1330

                }
            }
            case "SEQUENCE" -> {
                ObjectSource fromSequence = catalogSequenceSource(schema, name, objectType);
                if (fromSequence != null) {
                    return fromSequence;
                }
            }
            case "PROCEDURE", "FUNCTION", "PACKAGE", "PACKAGE_BODY", "TYPE", "TYPE_BODY" -> {
                ObjectSource fromAllSource = catalogRoutineSource(schema, name, objectType);
                if (fromAllSource != null) {
                    return fromAllSource;
                }
                ObjectSource fromSystemText = catalogRoutineSystemText(schema, name, objectType);
                if (fromSystemText != null) {
                    return fromSystemText;
                }
            }
            default -> throw new IllegalArgumentException("Unsupported object type: " + objectType);
        }
        return unavailableObjectSource(schema, name, objectType, dbmsError);
    }

    /**
     * 字典视图来源(ALL_VIEWS.TEXT / ALL_TRIGGERS.TRIGGER_BODY)通常只包含对象正文、
     * 不含完整的 CREATE/ALTER 语句头,不能作为可执行 DDL 保存,故标记为不可在线编辑。
     */
    private static final String CATALOG_BODY_HINT =
        "-- 以下内容来自系统字典视图,仅为对象正文,可能不包含完整语句头,不可在线编辑。\n";

    /** 读取单行单列文本(视图/触发器源码),空结果返回空串。 */
    private String scalarText(String sql, String schema, String name) throws Exception {
        try (PreparedStatement stmt = requireConnected().prepareStatement(sql)) {
            stmt.setString(1, schema);
            stmt.setString(2, name);
            try (ResultSet rs = stmt.executeQuery()) {
                return rs.next() ? coalesce(readTextColumn(rs, 1)) : "";

View on GitHub (pinned to c0390bff16)

Solutions

  1. Restrict source-retrieval calls to supported types: VIEW, MATERIALIZED_VIEW, TRIGGER, SEQUENCE, PROCEDURE, FUNCTION, PACKAGE, PACKAGE_BODY, TYPE, TYPE_BODY.
  2. Normalize the type before calling: trim, uppercase, replace spaces with underscores (mirroring normalizeObjectSourceType).
  3. For unsupported types, use getTableDdl for tables or skip source retrieval and mark the object as 'source unavailable'.
  4. Wrap in try-catch (IllegalArgumentException) and degrade gracefully in UI/tooling.
  5. If a type is genuinely needed, extend the switch in DamengAgent with a dictionary query for that kind.

Example fix

// before
ObjectSource src = damengAgent.getObjectSource(schema, "MY_INDEX", "INDEX"); // throws
// after
String normalized = objectType == null ? "" : objectType.trim().toUpperCase(Locale.ROOT).replace(' ', '_');
Set<String> supported = Set.of("VIEW","MATERIALIZED_VIEW","TRIGGER","SEQUENCE","PROCEDURE","FUNCTION","PACKAGE","PACKAGE_BODY","TYPE","TYPE_BODY");
ObjectSource src = supported.contains(normalized)
    ? damengAgent.getObjectSource(schema, name, objectType)
    : ObjectSource.unavailable(schema, name, objectType, "source not supported for " + normalized);
Defensive patterns

Strategy: validation

Validate before calling

String normalized = objectType == null ? "" : objectType.trim().toUpperCase(Locale.ROOT).replace(' ', '_');
Set<String> supported = Set.of("VIEW","MATERIALIZED_VIEW","TRIGGER","SEQUENCE","PROCEDURE","FUNCTION","PACKAGE","PACKAGE_BODY","TYPE","TYPE_BODY");
if (!supported.contains(normalized)) { /* skip or use unavailable-source placeholder */ }

Type guard

static boolean isDamengSourceableType(String objectType) {
    if (objectType == null) return false;
    String t = objectType.trim().toUpperCase(Locale.ROOT).replace(' ', '_');
    return Set.of("VIEW","MATERIALIZED_VIEW","TRIGGER","SEQUENCE","PROCEDURE","FUNCTION","PACKAGE","PACKAGE_BODY","TYPE","TYPE_BODY").contains(t);
}

Try / catch

try {
    ObjectSource src = damengAgent.getObjectSource(schema, name, objectType);
} catch (IllegalArgumentException e) {
    ObjectSource src = ObjectSource.unavailable(schema, name, objectType, "Dameng source not available for this type");
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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