pentaho/pentaho-kettle · error · UnsupportedOperationException

Cannot add converters

Error message

Cannot add converters

What it means

addConverter() is rejected because the converter map in ContentConverterHandler is fixed at construction; extensions cannot be extended at runtime. This is an explicit API contract guarding the immutable converter registry.

Solutions

  1. Do not call addConverter on ContentConverterHandler; register custom converters before constructing the handler if the constructor allows it
  2. Use getConverter for lookups and rely on the preconfigured set
  3. Fork/wrap the handler if you genuinely need dynamic converter registration

Example fix

// before
handler.addConverter( "xml", new XmlConverter() );
// after
Converter conv = handler.getConverter( "ktr" ); // use preconfigured converters only
Defensive patterns

Strategy: validation

Validate before calling

// Registration is not supported; verify converters are preconfigured
Converter c = handler.getConverter( extension );
if ( c == null ) {
  throw new IllegalStateException( "No preconfigured converter for " + extension + "; addConverter is unsupported" );
}

Try / catch

try {
  handler.addConverter( ext, conv );
} catch ( UnsupportedOperationException e ) {
  log.warn( "Converter registration unsupported: use preconfigured converters" );
}

Prevention

When it happens

Trigger: Calling addConverter(String extension, Converter) on a ContentConverterHandler instance, e.g. custom code trying to register a handler for a new file extension.

Common situations: Developers attempting to plug in support for additional repository file types; framework code that tries to register default converters after creation.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/ad5b3b9a002b2059. Report an issue: GitHub.

Appendix: source

Thrown at plugins/repo-vfs/repo-vfs-pur/src/main/java/org/pentaho/di/plugins/repofvs/pur/converter/ContentConverterHandler.java:56

  public Converter getConverter( String extension ) {
    if ( extension == null ) {
      return simpleConverter;
    }
    return switch ( extension.toLowerCase() ) {
      case Const.STRING_JOB_DEFAULT_EXT -> jobConverter;
      case Const.STRING_TRANS_DEFAULT_EXT -> transConverter;
      default -> simpleConverter;
    };
  }

  @Override
  public Map<String, Converter> getConverters() {
    throw new UnsupportedOperationException( "Use getConverter" );
  }

  @Override
  public void addConverter( String extension, Converter converter ) {
    throw new UnsupportedOperationException( "Cannot add converters" );
  }


}

View on GitHub (pinned to f3058517a1)