{"record":{"id":"9e915964b51c7f11","repo":"spring-projects/spring-framework","slug":"failed-to-convert-value-of-type-to-required-t","errorCode":null,"errorMessage":"Failed to convert value of type '{}' to required type '{}'","messagePattern":"Failed to convert value of type '(.+?)' to required type '(.+?)'","errorType":"exception","errorClass":"ConversionNotSupportedException","httpStatus":null,"severity":"error","filePath":"spring-beans/src/main/java/org/springframework/beans/TypeConverterSupport.java","lineNumber":79,"sourceCode":"\t}\n\n\t@Override\n\tpublic <T> @Nullable T convertIfNecessary(@Nullable Object value, @Nullable Class<T> requiredType,\n\t\t\t@Nullable TypeDescriptor typeDescriptor) throws TypeMismatchException {\n\n\t\treturn convertIfNecessary(null, value, requiredType, typeDescriptor);\n\t}\n\n\tprivate <T> @Nullable T convertIfNecessary(@Nullable String propertyName, @Nullable Object value,\n\t\t\t@Nullable Class<T> requiredType, @Nullable TypeDescriptor typeDescriptor) throws TypeMismatchException {\n\n\t\tAssert.state(this.typeConverterDelegate != null, \"No TypeConverterDelegate\");\n\t\ttry {\n\t\t\treturn this.typeConverterDelegate.convertIfNecessary(\n\t\t\t\t\tpropertyName, null, value, requiredType, typeDescriptor);\n\t\t}\n\t\tcatch (ConverterNotFoundException | IllegalStateException ex) {\n\t\t\tthrow new ConversionNotSupportedException(value, requiredType, ex);\n\t\t}\n\t\tcatch (ConversionException | IllegalArgumentException ex) {\n\t\t\tthrow new TypeMismatchException(value, requiredType, ex);\n\t\t}\n\t}\n\n}\n","sourceCodeStart":61,"sourceCodeEnd":87,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/69bf83ad716d0cfc4b0520a19b4d8b24c79d1538/spring-beans/src/main/java/org/springframework/beans/TypeConverterSupport.java#L61-L87","documentation":"ConversionNotSupportedException raised by TypeConverterSupport when the delegate throws ConverterNotFoundException or IllegalStateException (see error 186). It signals that the conversion could not even be attempted because no converter/strategy exists. Carries the source value and required type; propertyName may be null.","triggerScenarios":"convertIfNecessary on a BeanWrapper / TypeConverterSupport for a (value, requiredType) pair with no registered Converter or PropertyEditor, so the delegate raises IllegalStateException and line 79 wraps it.","commonSituations":"@Value injection, @ConfigurationProperties binding, or manual BeanWrapper.setPropertyValue where the target type has no converter; Spring Boot relaxed binding encountering an unregistered custom type.","solutions":["Register a Converter or PropertyEditor for the required type (same fixes as error 186).","Correct the target property type in the bean to a convertible type.","If the value is already correct, ensure ConversionService is actually wired into the BeanWrapper (setConversionService)."],"exampleFix":"// before\nwrapper.setConversionService(null);\nwrapper.setPropertyValue(\"when\", \"2023-01-01\"); // target java.time.Instant, no converter\n\n// after\nDefaultConversionService cs = new DefaultConversionService();\ncs.addConverter(String.class, Instant.class, Instant::parse);\nwrapper.setConversionService(cs);\nwrapper.setPropertyValue(\"when\", \"2023-01-01T00:00:00Z\");","handlingStrategy":"try-catch","validationCode":"// Pre-check before converting\nif (!conversionService.canConvert(TypeDescriptor.forObject(value), TypeDescriptor.valueOf(requiredType))) {\n    throw new IllegalStateException(\"unsupported conversion; register a converter\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    T result = converter.convertIfNecessary(value, requiredType, descriptor);\n} catch (ConversionNotSupportedException ex) {\n    // no converter exists — register one and retry, or fail with context\n    log.warn(\"No converter for {} -> {}\", value.getClass(), requiredType, ex);\n    throw ex;\n}","preventionTips":["Ensure ConversionService is set on the BeanWrapper before binding.","Register Converters for all custom types at startup.","Use canConvert() to fail fast in integration tests."],"tags":["type-conversion","binding","conversion-unsupported"],"backgroundTag":null,"analyzedSha":"69bf83ad716d0cfc4b0520a19b4d8b24c79d1538","analyzedAt":"2026-08-09T15:32:58.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}