alibaba/nacos · warning · MissingFormatArgumentException

converter not found, can't convert from String to {}

Error message

converter not found, can't convert from String to {}

What it means

Thrown by CompositeConverter.convert() as a MissingFormatArgumentException when no converter is registered for the requested target class. The registry only contains converters for Boolean.class, Integer.class, and Long.class. Requesting conversion to any other type (e.g. Double.class, String.class, Float.class) triggers this exception. The message includes the canonical name of the unsupported target class.

Source

Thrown at client-basic/src/main/java/com/alibaba/nacos/client/env/convert/CompositeConverter.java:47

    private final Map<Class<?>, AbstractPropertyConverter<?>> converterRegistry = new HashMap<>();
    
    public CompositeConverter() {
        converterRegistry.put(Boolean.class, new BooleanConverter());
        converterRegistry.put(Integer.class, new IntegerConverter());
        converterRegistry.put(Long.class, new LongConverter());
    }
    
    /**
     * convert property to target type.
     * @param property the property gets from environments
     * @param targetClass target class object
     * @param <T> target type
     * @return the object of target type
     */
    public <T> T convert(String property, Class<T> targetClass) {
        final AbstractPropertyConverter<?> converter = converterRegistry.get(targetClass);
        if (converter == null) {
            throw new MissingFormatArgumentException(
                "converter not found, can't convert from String to "
                    + targetClass.getCanonicalName());
        }
        return (T) converter.convert(property);
    }
    
}

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. If you need Double, Short, or Float conversion, register a custom AbstractPropertyConverter and add it to the CompositeConverter registry.
  2. For end-user code, retrieve the property as a String and parse it manually rather than relying on the converter registry.
  3. If you believe a built-in type should be supported, check if a newer Nacos version added the converter.

Example fix

// before — requesting unsupported type
Double val = compositeConverter.convert("3.14", Double.class);

// after — parse manually
Double val = Double.parseDouble(properties.getProperty("some.key"));
Defensive patterns

Strategy: validation

Validate before calling

Set<Class<?>> supported = Set.of(Boolean.class, Integer.class, Long.class);
if (!supported.contains(targetClass)) {
    // Parse manually instead of using CompositeConverter
    String raw = properties.getProperty(key);
    // ... parse raw to targetClass manually
}

Try / catch

try {
    T value = compositeConverter.convert(property, targetClass);
} catch (MissingFormatArgumentException e) {
    // No converter for this type — handle by manual parsing or skipping
    return null;
}

Prevention

When it happens

Trigger: Calling NacosClientProperties.getProperty(key, SomeOtherType.class) where SomeOtherType is not Boolean, Integer, or Long. This is typically an internal API used by the Nacos client framework itself, not by end users directly.

Common situations: Extending NacosClientProperties and requesting a Double, Short, Float, or custom type; framework code requesting an unregistered type; a new property type was added to the client without registering a converter.

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/1fc5b14e05d29b38. Report an issue: GitHub.