apache/seatunnel · error · RuntimeException

Unsupported config type, configKey

Error message

Unsupported config type, configKey: ${configKey}

What it means

TypesafeConfigUtils.getConfig extracts a typed value from a Typesafe Config by inspecting the runtime type of the provided defaultValue to decide how to parse. It supports String, Number, Boolean, Map and List defaults; any other default type falls through to a RuntimeException naming the config key.

Solutions

  1. Change the defaultValue argument to a supported type: String, Integer/Double (Number), Boolean, Map, or List
  2. Read the raw value with config.getValue(key) / config.getAnyRef(key) and convert manually for unsupported types
  3. For null defaults, wrap the read in config.hasPath(key) yourself and parse with the concrete Typesafe getter (getString, getInt, etc.)

Example fix

// before
MyOptions opts = TypesafeConfigUtils.getConfig(config, "opts", new MyOptions()); // throws
// after
Map<String, Object> opts = TypesafeConfigUtils.getConfig(config, "opts", Collections.emptyMap());
Defensive patterns

Strategy: type-guard

Validate before calling

if (defaultValue != null && !(defaultValue instanceof String) && !(defaultValue instanceof Number) && !(defaultValue instanceof Boolean) && !(defaultValue instanceof Map) && !(defaultValue instanceof List)) throw new IllegalArgumentException("unsupported default type for " + configKey);

Type guard

static boolean isSupportedDefault(Object d) { return d instanceof String || d instanceof Number || d instanceof Boolean || d instanceof Map || d instanceof List; }

Try / catch

try { return TypesafeConfigUtils.getConfig(config, key, def); } catch (RuntimeException e) { return (T) config.getAnyRef(key); }

Prevention

When it happens

Trigger: Calling TypesafeConfigUtils.getConfig(config, key, defaultValue) where defaultValue is of an unsupported type (e.g. a custom object, enum, Long wrapped oddly, null, or nested non-primitive wrapper).

Common situations: Passing a POJO/enum as default; passing null (type cannot be inferred); copy-pasted helper usage with an exotic default type; assuming getConfig supports types beyond primitives and collections.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/99206339990f0f04. Report an issue: GitHub.

Appendix: source

Thrown at seatunnel-common/src/main/java/org/apache/seatunnel/common/config/TypesafeConfigUtils.java:83

                    : defaultValue;
        }
        if (defaultValue.getClass().equals(Integer.class)) {
            return config.hasPath(configKey)
                    ? (T) Integer.valueOf(config.getString(configKey))
                    : defaultValue;
        }
        if (defaultValue.getClass().equals(String.class)) {
            return config.hasPath(configKey) ? (T) config.getString(configKey) : defaultValue;
        }
        if (defaultValue.getClass().equals(Boolean.class)) {
            return config.hasPath(configKey)
                    ? (T) Boolean.valueOf(config.getString(configKey))
                    : defaultValue;
        }
        if (defaultValue instanceof Map || defaultValue instanceof List) {
            return config.hasPath(configKey) ? (T) config.getAnyRef(configKey) : defaultValue;
        }
        throw new RuntimeException("Unsupported config type, configKey: " + configKey);
    }

    public static List<? extends Config> getConfigList(
            Config config, String configKey, @NonNull List<? extends Config> defaultValue) {
        return config.hasPath(configKey) ? config.getConfigList(configKey) : defaultValue;
    }

    public static Map<String, String> configToMap(Config config) {
        Map<String, String> configMap = new HashMap<>();
        config.entrySet()
                .forEach(
                        entry -> {
                            configMap.put(entry.getKey(), entry.getValue().unwrapped().toString());
                        });
        return configMap;
    }
}

View on GitHub (pinned to cf67b549a7)