apache/dubbo · error · IllegalArgumentException

Illegal type of parameter 'config' : <config.getClass().getN

Error message

Illegal type of parameter 'config' : <config.getClass().getName()>

What it means

Thrown by ModuleConfigManager.findDuplicatedInterfaceConfig() when the supplied AbstractInterfaceConfig is neither a ReferenceConfigBase nor a ServiceConfigBase. The duplicate-detection logic only handles service (and returns early for reference) configs; any other AbstractInterfaceConfig subtype is invalid input and rejected with IllegalArgumentException naming the actual class.

Source

Thrown at dubbo-common/src/main/java/org/apache/dubbo/config/context/ModuleConfigManager.java:239

        return false;
    }

    /**
     * check duplicated ReferenceConfig/ServiceConfig
     *
     * @param config
     */
    private AbstractInterfaceConfig findDuplicatedInterfaceConfig(AbstractInterfaceConfig config) {
        String uniqueServiceName;
        Map<String, AbstractInterfaceConfig> configCache;
        if (config instanceof ReferenceConfigBase) {
            return null;
        } else if (config instanceof ServiceConfigBase) {
            ServiceConfigBase serviceConfig = (ServiceConfigBase) config;
            uniqueServiceName = serviceConfig.getUniqueServiceName();
            configCache = serviceConfigCache;
        } else {
            throw new IllegalArgumentException(
                    "Illegal type of parameter 'config' : " + config.getClass().getName());
        }

        AbstractInterfaceConfig prevConfig = configCache.putIfAbsent(uniqueServiceName, config);
        if (prevConfig != null) {
            if (prevConfig == config) {
                return prevConfig;
            }

            if (prevConfig.equals(config)) {
                // Is there any problem with ignoring duplicate and equivalent but different ReferenceConfig instances?
                if (logger.isWarnEnabled() && duplicatedConfigs.add(config)) {
                    logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "Ignore duplicated and equal config: " + config);
                }
                return prevConfig;
            }

            String configType = config.getClass().getSimpleName();

View on GitHub (pinned to 3a3043227f)

Solutions

  1. Only pass ServiceConfigBase or ReferenceConfigBase instances to interface-level config registration.
  2. If you have a custom config type, register it via the generic addConfig path rather than the interface dedup path.
  3. Ensure your config extends the correct base class (ServiceConfigBase/ReferenceConfigBase).

Example fix

// before
class MyConfig extends AbstractInterfaceConfig { }
moduleConfigManager.findDuplicatedInterfaceConfig(myConfig); // throws
// after
class MyServiceConfig extends ServiceConfigBase { }
Defensive patterns

Strategy: type-guard

Validate before calling

AbstractInterfaceConfig cfg = ...;
if (!(cfg instanceof ServiceConfigBase) && !(cfg instanceof ReferenceConfigBase)) {
    throw new IllegalArgumentException("Config must be ServiceConfigBase or ReferenceConfigBase: " + cfg.getClass());
}
moduleConfigManager.addConfig(cfg);

Type guard

static boolean isInterfaceConfigBase(AbstractConfig c) {
    return c instanceof ServiceConfigBase || c instanceof ReferenceConfigBase;
}

Try / catch

try {
    moduleConfigManager.addConfig(cfg);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Illegal type of parameter 'config'")) {
        // wrap as a ServiceConfigBase/ReferenceConfigBase instead
    } else throw e;
}

Prevention

When it happens

Trigger: Calling the module manager's internal interface-duplicate check with a custom AbstractInterfaceConfig subclass that is not ServiceConfigBase or ReferenceConfigBase. Framework extension code passing an unexpected config subtype.

Common situations: Custom config subclasses introduced by integrations that bypass the standard service/reference config hierarchy. Incorrectly routing a non-interface config through the interface dedup path.

Related errors


AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14). Data as JSON: /api/errors/298939366606917b. Report an issue: GitHub.