t8y2/dbx · error · IllegalArgumentException
Unsupported object type: " + objectType
Error message
Unsupported object type: " + objectType
What it means
OscarAgent.getObjectSource supports VIEW, PROCEDURE, FUNCTION, PACKAGE, PACKAGE_BODY, TYPE, TYPE_BODY, TRIGGER and SEQUENCE. The Shentong (神通) v7 catalog has no ALL_MVIEWS view, so MATERIALIZED_VIEW returns empty source (marked non-editable), and every other type throws IllegalArgumentException because no source-reading path exists for it.
Source
Thrown at agents/drivers/oscar/src/main/java/com/dbx/agent/oscar/OscarAgent.java:79
* <li>VIEW → ALL_VIEWS.TEXT(返回完整 SELECT 语句)</li>
* <li>PROCEDURE/FUNCTION/PACKAGE/PACKAGE_BODY/TYPE/TYPE_BODY → ALL_SOURCE.TEXT 按 LINE 排序拼接</li>
* <li>TRIGGER → ALL_TRIGGERS.TRIGGER_BODY</li>
* <li>SEQUENCE → 由 ALL_SEQUENCES 元数据重建 CREATE SEQUENCE 语句</li>
* <li>MATERIALIZED_VIEW → 神通无 ALL_MVIEWS,返回空源码且不可编辑</li>
* </ul>
*/
@Override
public ObjectSource getObjectSource(String schema, String name, String objectType) {
String type = objectType == null ? "" : objectType.trim().toUpperCase(Locale.ROOT);
return unchecked(() -> {
String source = switch (type) {
case "VIEW" -> readViewSource(schema, name);
case "PROCEDURE", "FUNCTION", "PACKAGE", "PACKAGE_BODY", "TYPE", "TYPE_BODY" -> readSourceText(schema, name, type);
case "TRIGGER" -> readTriggerSource(schema, name);
case "SEQUENCE" -> readSequenceSource(schema, name);
// 神通 v7 无物化视图系统视图(ALL_MVIEWS 不存在);返回空源码,标记不可编辑,避免 UI 误判为可改。
case "MATERIALIZED_VIEW" -> "";
default -> throw new IllegalArgumentException("Unsupported object type: " + objectType);
};
boolean editable = !"MATERIALIZED_VIEW".equals(type);
return new ObjectSource(name, objectType, schema, source, editable);
});
}
private String readViewSource(String schema, String name) throws Exception {
// ALL_VIEWS.TEXT 已包含完整视图定义(神通实测返回带 schema 限定的 SELECT 语句)。
String sql = "SELECT TEXT FROM ALL_VIEWS WHERE OWNER = ? AND VIEW_NAME = ?";
return scalarText(sql, schema, name);
}
private String readSourceText(String schema, String name, String type) throws Exception {
// ALL_SOURCE 按 LINE 存储过程/函数/包/类型的源码行,需按 LINE 排序拼接。
// 神通与 Oracle 的关键差异(实测 v7.0.8):function 也以 TYPE='PROCEDURE' 存储(不区分 FUNCTION),
// 包体随包一起存为 TYPE='PACKAGE',类型体随类型存为 TYPE='TYPE'。故按 objectType 归并到实际 TYPE 值。
String sourceType = switch (type) {
case "PROCEDURE", "FUNCTION" -> "PROCEDURE";View on GitHub (pinned to c0390bff16)
Solutions
- Restrict source requests to the supported set (VIEW, PROCEDURE, FUNCTION, PACKAGE, PACKAGE_BODY, TYPE, TYPE_BODY, TRIGGER, SEQUENCE).
- Normalize the type string (trim/uppercase, spaces to underscores) and handle MATERIALIZED_VIEW as empty/non-editable as the driver does.
- For unsupported kinds, skip source retrieval in the caller and display a 'source not available' state instead of calling the API.
Example fix
// before
var src = agent.getObjectSource(schema, name, "SYNONYM"); // throws
// after
if (Set.of("VIEW","PROCEDURE","FUNCTION","PACKAGE","PACKAGE_BODY","TYPE","TYPE_BODY","TRIGGER","SEQUENCE","MATERIALIZED_VIEW")
.contains(type.toUpperCase(Locale.ROOT))) {
var src = agent.getObjectSource(schema, name, type.toUpperCase(Locale.ROOT));
} Defensive patterns
Strategy: validation
Validate before calling
Set<String> SUPPORTED = Set.of("VIEW","PROCEDURE","FUNCTION","PACKAGE","PACKAGE_BODY","TYPE","TYPE_BODY","TRIGGER","SEQUENCE","MATERIALIZED_VIEW");
if (objectType == null || !SUPPORTED.contains(objectType.toUpperCase(Locale.ROOT))) {
// skip source retrieval / show "source unavailable"
} Type guard
boolean oscarSupportsSource(String t) {
return t != null && Set.of("VIEW","PROCEDURE","FUNCTION","PACKAGE","PACKAGE_BODY","TYPE","TYPE_BODY","TRIGGER","SEQUENCE","MATERIALIZED_VIEW")
.contains(t.trim().toUpperCase(Locale.ROOT));
} Try / catch
try {
source = agent.getObjectSource(schema, name, type);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Unsupported object type")) {
source = ""; // render as non-editable/no source
} else throw e;
} Prevention
- Gate the 'view source' action on the supported-type set in the UI layer.
- Normalize type strings before calling; treat MATERIALIZED_VIEW as empty/non-editable like the driver does.
- For unsupported kinds, query Oscar catalog views directly instead of getObjectSource.
When it happens
Trigger: Calling getObjectSource(schema, name, objectType) on OscarAgent with a type outside the switch — e.g. "SYNONYM", "DBLINK", "INDEX", a misspelled type, or an unnormalized label containing spaces/lowercase.
Common situations: A generic database explorer iterates all catalog object kinds and requests source for each; new Oscar object types appear in a version the driver predates; UI passes raw user-entered type strings without normalization.
Related errors
- Unsupported object type: " + objectType
- Unsupported object type: " + objectType
- Unsupported object type: " + objectType
- Unsupported object type: null
- Unsupported object type: " + objectType
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/a6e60f4acd49b105.
Report an issue: GitHub.