{"record":{"id":"4dcb8c4504867c95","repo":"pentaho/pentaho-kettle","slug":"unsupported-data-source-type-type","errorCode":null,"errorMessage":"Unsupported data source type: \" + type","messagePattern":"Unsupported data source type: \" \\+ type","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/util/DatabaseUtil.java","lineNumber":192,"sourceCode":"    } finally {\n      Thread.currentThread().setContextClassLoader( original );\n    }\n\n  }\n\n  @Override\n  public DataSource getNamedDataSource( String datasourceName, DatasourceType type )\n    throws DataSourceNamingException {\n    if ( type != null ) {\n      switch ( type ) {\n        case JNDI:\n          return getNamedDataSource( datasourceName );\n        case POOLED:\n          throw new UnsupportedOperationException(\n            getClass().getName() + \" does not support providing pooled data sources\" );\n      }\n    }\n    throw new IllegalArgumentException( \"Unsupported data source type: \" + type );\n  }\n\n  @Override public DataSource invalidateNamedDataSource( String datasourceName, DatasourceType type )\n    throws DataSourceNamingException {\n\n    switch ( type ) {\n      case POOLED:\n        return ConnectionPoolUtil.removeDataSource( datasourceName );\n      default:\n        return FoundDS.remove( datasourceName );\n    }\n  }\n}\n","sourceCodeStart":174,"sourceCodeEnd":206,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/util/DatabaseUtil.java#L174-L206","documentation":"getNamedDataSource throws IllegalArgumentException with 'Unsupported data source type: <type>' when the DatasourceType is null or not one of the handled cases (JNDI, POOLED). It is the default/exhaustive guard at the end of the switch.","triggerScenarios":"Calling getNamedDataSource with a null DatasourceType, or with an enum value added in a newer version of DatasourceType that this switch does not handle yet.","commonSituations":"Configuration deserialization producing a null type, API drift after adding a new DatasourceType constant, or passing the wrong enum between modules.","solutions":["Pass a valid DatasourceType (JNDI or POOLED) — check for null before the call.","Fix whatever deserialization/config is producing a null or unknown type.","If a new enum constant exists, extend the switch in the provider to handle it.","Catch IllegalArgumentException and validate the type against DatasourceType.values() first."],"exampleFix":"// before\nDataSource ds = util.getNamedDataSource( config.getType(), name ); // getType() may be null\n// after\nDatasourceType t = config.getType();\nif ( t == null ) { t = DatasourceType.JNDI; }\nDataSource ds = util.getNamedDataSource( t, name );","handlingStrategy":"type-guard","validationCode":"boolean isKnownType( DatasourceType t ) {\n  return t != null && ( t == DatasourceType.JNDI || t == DatasourceType.POOLED );\n}","typeGuard":"DatasourceType safeType( DatasourceType t ) {\n  return t == null ? DatasourceType.JNDI : t;\n}","tryCatchPattern":"try {\n  ds = util.getNamedDataSource( type, name );\n} catch ( IllegalArgumentException e ) {\n  throw new IllegalStateException( \"Bad datasource type in config: \" + type, e );\n}","preventionTips":["Null-check enum values deserialized from config","Handle new DatasourceType constants in every switch (avoid silent default)","Pin Kettle module versions to avoid enum drift"],"tags":["invalid-argument","enum","datasource"],"backgroundTag":"invalid-enum-value","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}