{"record":{"id":"1fc5b14e05d29b38","repo":"alibaba/nacos","slug":"converter-not-found-can-t-convert-from-string-to","errorCode":null,"errorMessage":"converter not found, can't convert from String to {}","messagePattern":"converter not found, can't convert from String to (.+?)","errorType":"exception","errorClass":"MissingFormatArgumentException","httpStatus":null,"severity":"warning","filePath":"client-basic/src/main/java/com/alibaba/nacos/client/env/convert/CompositeConverter.java","lineNumber":47,"sourceCode":"    private final Map<Class<?>, AbstractPropertyConverter<?>> converterRegistry = new HashMap<>();\n    \n    public CompositeConverter() {\n        converterRegistry.put(Boolean.class, new BooleanConverter());\n        converterRegistry.put(Integer.class, new IntegerConverter());\n        converterRegistry.put(Long.class, new LongConverter());\n    }\n    \n    /**\n     * convert property to target type.\n     * @param property the property gets from environments\n     * @param targetClass target class object\n     * @param <T> target type\n     * @return the object of target type\n     */\n    public <T> T convert(String property, Class<T> targetClass) {\n        final AbstractPropertyConverter<?> converter = converterRegistry.get(targetClass);\n        if (converter == null) {\n            throw new MissingFormatArgumentException(\n                \"converter not found, can't convert from String to \"\n                    + targetClass.getCanonicalName());\n        }\n        return (T) converter.convert(property);\n    }\n    \n}\n","sourceCodeStart":29,"sourceCodeEnd":55,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/client-basic/src/main/java/com/alibaba/nacos/client/env/convert/CompositeConverter.java#L29-L55","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["If you need Double, Short, or Float conversion, register a custom AbstractPropertyConverter and add it to the CompositeConverter registry.","For end-user code, retrieve the property as a String and parse it manually rather than relying on the converter registry.","If you believe a built-in type should be supported, check if a newer Nacos version added the converter."],"exampleFix":"// before — requesting unsupported type\nDouble val = compositeConverter.convert(\"3.14\", Double.class);\n\n// after — parse manually\nDouble val = Double.parseDouble(properties.getProperty(\"some.key\"));","handlingStrategy":"validation","validationCode":"Set<Class<?>> supported = Set.of(Boolean.class, Integer.class, Long.class);\nif (!supported.contains(targetClass)) {\n    // Parse manually instead of using CompositeConverter\n    String raw = properties.getProperty(key);\n    // ... parse raw to targetClass manually\n}","typeGuard":null,"tryCatchPattern":"try {\n    T value = compositeConverter.convert(property, targetClass);\n} catch (MissingFormatArgumentException e) {\n    // No converter for this type — handle by manual parsing or skipping\n    return null;\n}","preventionTips":["Only request Boolean, Integer, or Long from CompositeConverter; parse other types manually.","Register custom converters if you need additional types.","Catch MissingFormatArgumentException specifically for unsupported-type scenarios."],"tags":["type-conversion","configuration","internal-api","unsupported-type"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}