dbeaver/dbeaver · error · DBException

`type` attribute is mandatory

Error message

`type` attribute is mandatory

What it means

Thrown by SQLPragmaExport.processPragma when the 'type' parameter is missing or empty in the pragma parameter map. This pragma drives stream-based data export; 'type' selects which stream processor (csv, json, sql, etc.) to use. Without it the registry lookup cannot be formed.

Source

Thrown at plugins/org.jkiss.dbeaver.data.transfer.ui/src/org/jkiss/dbeaver/tools/transfer/ui/SQLPragmaExport.java:65

    private static final Log log = Log.getLog(SQLPragmaExport.class);

    public static final String PARAMETER_TYPE = "type";
    public static final String PARAMETER_INCLUDE_PIPES = "includePipesConfiguration";

    private static final String PRODUCER_NODE_ID = "database_producer";
    private static final String CONSUMER_NODE_ID = "stream_consumer";
    private static final String PROCESSOR_ID_PREFIX = CONSUMER_NODE_ID + ":stream.";

    @Override
    public int processPragma(
        @NotNull DBRProgressMonitor monitor,
        @NotNull DBSDataContainer container,
        @NotNull Map<String, Object> parameters
    ) throws DBException {
        final String type = JSONUtils.getString(parameters, PARAMETER_TYPE);
        final boolean includePipes = JSONUtils.getBoolean(parameters, PARAMETER_INCLUDE_PIPES, false);
        if (CommonUtils.isEmpty(type)) {
            throw new DBException("`type` attribute is mandatory");
        }

        final DataTransferRegistry registry = DataTransferRegistry.getInstance();
        final DataTransferNodeDescriptor producerNode = registry.getNodeById(PRODUCER_NODE_ID);
        final DataTransferNodeDescriptor consumerNode = registry.getNodeById(CONSUMER_NODE_ID);
        final DataTransferProcessorDescriptor processor = registry.getProcessor(PROCESSOR_ID_PREFIX + type);

        if (processor == null) {
            throw new DBException("Can't find processor of type '" + type + "'");
        }

        final DataTransferSettings settings = new DataTransferSettings(
            Collections.singleton(new DatabaseTransferProducer(container, null)),
            Collections.singleton(new StreamTransferConsumer()),
            Map.of(
                DTConstants.PROP_PRODUCER_TYPE, producerNode.getId(),
                DTConstants.PROP_CONSUMER_TYPE, consumerNode.getId(),
                DTConstants.PROP_PROCESSOR_TYPE, processor.getId(),

View on GitHub (pinned to 1e5ee1042b)

Solutions

  1. Add the mandatory 'type' parameter to the pragma call, e.g. type="csv" or type="json", matching a registered stream processor id.
  2. If invoking programmatically, set parameters.put(PARAMETER_TYPE, "csv") before calling processPragma.
  3. Document/validate the pragma schema at the call site so missing 'type' is caught earlier with a clearer message.

Example fix

// before - missing type
processPragma(monitor, container, Map.of("includePipes", true)); // throws

// after
processPragma(monitor, container, Map.of("type", "csv", "includePipes", true));
Defensive patterns

Strategy: validation

Validate before calling

// Validate mandatory 'type' before calling processPragma
String type = JSONUtils.getString(parameters, PARAMETER_TYPE);
if (CommonUtils.isEmpty(type)) {
    throw new DBException("`type` attribute is mandatory; expected one of: csv, json, html, sql, ...");
}

Type guard

static boolean hasValidType(Map<String,Object> p) {
    String t = p == null ? null : JSONUtils.getString(p, PARAMETER_TYPE);
    return t != null && !t.isBlank();
}

Try / catch

try {
    sqlPragmaExport.processPragma(monitor, container, parameters);
} catch (DBException e) {
    if (e.getMessage().contains("`type` attribute is mandatory")) {
        // prompt user / supply default type
    }
    throw e;
}

Prevention

When it happens

Trigger: Invoking the SQL pragma export with a parameter map that omits PARAMETER_TYPE, sets it to null, or sets it to an empty string. JSONUtils.getString returns null/empty and CommonUtils.isEmpty trips the guard.

Common situations: A malformed pragma statement in a SQL script (missing the type argument); a programmatic call to processPragma that built the parameters map incompletely; version drift where the pragma schema added the mandatory 'type' but the caller was written against an older schema.

Related errors


AI-assisted analysis of dbeaver/dbeaver@1e5ee1042b (2026-08-13). Data as JSON: /api/errors/7043d16901b618e3. Report an issue: GitHub.