{"record":{"id":"7043d16901b618e3","repo":"dbeaver/dbeaver","slug":"type-attribute-is-mandatory","errorCode":null,"errorMessage":"`type` attribute is mandatory","messagePattern":"`type` attribute is mandatory","errorType":"validation","errorClass":"DBException","httpStatus":null,"severity":"error","filePath":"plugins/org.jkiss.dbeaver.data.transfer.ui/src/org/jkiss/dbeaver/tools/transfer/ui/SQLPragmaExport.java","lineNumber":65,"sourceCode":"    private static final Log log = Log.getLog(SQLPragmaExport.class);\n\n    public static final String PARAMETER_TYPE = \"type\";\n    public static final String PARAMETER_INCLUDE_PIPES = \"includePipesConfiguration\";\n\n    private static final String PRODUCER_NODE_ID = \"database_producer\";\n    private static final String CONSUMER_NODE_ID = \"stream_consumer\";\n    private static final String PROCESSOR_ID_PREFIX = CONSUMER_NODE_ID + \":stream.\";\n\n    @Override\n    public int processPragma(\n        @NotNull DBRProgressMonitor monitor,\n        @NotNull DBSDataContainer container,\n        @NotNull Map<String, Object> parameters\n    ) throws DBException {\n        final String type = JSONUtils.getString(parameters, PARAMETER_TYPE);\n        final boolean includePipes = JSONUtils.getBoolean(parameters, PARAMETER_INCLUDE_PIPES, false);\n        if (CommonUtils.isEmpty(type)) {\n            throw new DBException(\"`type` attribute is mandatory\");\n        }\n\n        final DataTransferRegistry registry = DataTransferRegistry.getInstance();\n        final DataTransferNodeDescriptor producerNode = registry.getNodeById(PRODUCER_NODE_ID);\n        final DataTransferNodeDescriptor consumerNode = registry.getNodeById(CONSUMER_NODE_ID);\n        final DataTransferProcessorDescriptor processor = registry.getProcessor(PROCESSOR_ID_PREFIX + type);\n\n        if (processor == null) {\n            throw new DBException(\"Can't find processor of type '\" + type + \"'\");\n        }\n\n        final DataTransferSettings settings = new DataTransferSettings(\n            Collections.singleton(new DatabaseTransferProducer(container, null)),\n            Collections.singleton(new StreamTransferConsumer()),\n            Map.of(\n                DTConstants.PROP_PRODUCER_TYPE, producerNode.getId(),\n                DTConstants.PROP_CONSUMER_TYPE, consumerNode.getId(),\n                DTConstants.PROP_PROCESSOR_TYPE, processor.getId(),","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/dbeaver/dbeaver/blob/1e5ee1042bc61661368942aece126f3e67049955/plugins/org.jkiss.dbeaver.data.transfer.ui/src/org/jkiss/dbeaver/tools/transfer/ui/SQLPragmaExport.java#L47-L83","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add the mandatory 'type' parameter to the pragma call, e.g. type=\"csv\" or type=\"json\", matching a registered stream processor id.","If invoking programmatically, set parameters.put(PARAMETER_TYPE, \"csv\") before calling processPragma.","Document/validate the pragma schema at the call site so missing 'type' is caught earlier with a clearer message."],"exampleFix":"// before - missing type\nprocessPragma(monitor, container, Map.of(\"includePipes\", true)); // throws\n\n// after\nprocessPragma(monitor, container, Map.of(\"type\", \"csv\", \"includePipes\", true));","handlingStrategy":"validation","validationCode":"// Validate mandatory 'type' before calling processPragma\nString type = JSONUtils.getString(parameters, PARAMETER_TYPE);\nif (CommonUtils.isEmpty(type)) {\n    throw new DBException(\"`type` attribute is mandatory; expected one of: csv, json, html, sql, ...\");\n}","typeGuard":"static boolean hasValidType(Map<String,Object> p) {\n    String t = p == null ? null : JSONUtils.getString(p, PARAMETER_TYPE);\n    return t != null && !t.isBlank();\n}","tryCatchPattern":"try {\n    sqlPragmaExport.processPragma(monitor, container, parameters);\n} catch (DBException e) {\n    if (e.getMessage().contains(\"`type` attribute is mandatory\")) {\n        // prompt user / supply default type\n    }\n    throw e;\n}","preventionTips":["Always include 'type' in the pragma parameters map.","Document the mandatory pragma schema at the call site.","Validate the parameter map shape before invoking the pragma."],"tags":["pragma","data-transfer","stream-export","validation","configuration"],"backgroundTag":null,"analyzedSha":"1e5ee1042bc61661368942aece126f3e67049955","analyzedAt":"2026-08-13T23:31:13.467Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}