t8y2/dbx · error · UnsupportedOperationException

Object source is not supported

Error message

Object source is not supported

What it means

The default getObjectSource() on the DatabaseAgent interface throws UnsupportedOperationException because viewing object source code (procedure/view/function bodies) requires database-specific catalog queries. Only agents that implement source extraction override this method; on others the call fails immediately.

Source

Thrown at agents/common/src/main/java/com/dbx/agent/DatabaseAgent.java:79

        return result;
    }

    default List<ObjectInfo> listObjects(String schema, MetadataListConstraints constraints) {
        return MetadataListConstraints.orNone(constraints).filterObjects(listObjects(schema));
    }

    default List<String> listDataTypes() {
        return Collections.emptyList();
    }

    default CompletionAssistantResponse completionAssistantSearch(CompletionAssistantRequest request) {
        throw new UnsupportedOperationException("Completion assistant search is not supported by this agent");
    }

    List<ColumnInfo> getColumns(String schema, String table);

    default ObjectSource getObjectSource(String schema, String name, String objectType) {
        throw new UnsupportedOperationException("Object source is not supported");
    }

    default String getTableDdl(String schema, String table) {
        List<IndexInfo> indexes;
        try {
            indexes = listIndexes(schema, table);
        } catch (RuntimeException e) {
            indexes = Collections.emptyList();
        }

        List<ForeignKeyInfo> foreignKeys;
        try {
            foreignKeys = listForeignKeys(schema, table);
        } catch (RuntimeException e) {
            foreignKeys = Collections.emptyList();
        }

        String tableComment = null;

View on GitHub (pinned to c0390bff16)

Solutions

  1. Guard the call with a capability check (instanceof an interface or a supportsObjectSource() flag) and show 'source not available' in the UI.
  2. Implement getObjectSource in the agent for the target database using its catalog (e.g. ALL_SOURCE, pg_get_functiondef, sp_helptext).
  3. Fall back to DDL reconstruction via getTableDdl/DdlBuilder where source is unavailable.

Example fix

// before
String src = agent.getObjectSource(schema, name, objectType);
// after
String src = supportsObjectSource(agent)
    ? agent.getObjectSource(schema, name, objectType)
    : agent.getTableDdl(schema, name); // fallback or show 'not available'
Defensive patterns

Strategy: fallback

Validate before calling

if (agent.getConnection() == null || !(agent instanceof SourceCapable)) { /* show 'source not available' */ }

Type guard

static boolean supportsObjectSource(DatabaseAgent a) {
    return a instanceof SourceCapable;
}

Try / catch

try {
    return agent.getObjectSource(schema, name, objectType);
} catch (UnsupportedOperationException e) {
    return agent.getTableDdl(schema, name); // graceful degradation
}

Prevention

When it happens

Trigger: Calling agent.getObjectSource(schema, name, objectType) on an implementation that does not override the default — e.g. requesting the source of a view/procedure on a database whose agent lacks source extraction.

Common situations: A database object explorer's 'View source' action is used against a database type that does not support source retrieval (or whose agent hasn't implemented it); the objectType passed is one the agent could never decompile anyway.

Related errors


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