{"record":{"id":"3f6dd6c86c7bc46c","repo":"junit-team/junit5","slug":"argumentconverter-does-not-override-the-convert-ob","errorCode":null,"errorMessage":"ArgumentConverter does not override the convert(Object, FieldContext) method. Please report this issue to the maintainers of %s.","messagePattern":"ArgumentConverter does not override the convert\\(Object, FieldContext\\) method\\. Please report this issue to the maintainers of (.+?)\\.","errorType":"exception","errorClass":"JUnitException","httpStatus":null,"severity":"error","filePath":"junit-jupiter-params/src/main/java/org/junit/jupiter/params/converter/ArgumentConverter.java","lineNumber":90,"sourceCode":"\t@Nullable\n\tObject convert(@Nullable Object source, ParameterContext context) throws ArgumentConversionException;\n\n\t/**\n\t * Convert the supplied {@code source} object according to the supplied\n\t * {@code context}.\n\t *\n\t * @param source the source object to convert; may be {@code null}\n\t * @param context the field context where the converted object will be\n\t * injected; never {@code null}\n\t * @return the converted object; may be {@code null} but only if the target\n\t * type is a reference type\n\t * @throws ArgumentConversionException if an error occurs during the\n\t * conversion\n\t * @since 5.13\n\t */\n\t@API(status = EXPERIMENTAL, since = \"6.0\")\n\tdefault @Nullable Object convert(@Nullable Object source, FieldContext context) throws ArgumentConversionException {\n\t\tthrow new JUnitException(\"\"\"\n\t\t\t\tArgumentConverter does not override the convert(Object, FieldContext) method. \\\n\t\t\t\tPlease report this issue to the maintainers of %s.\"\"\".formatted(getClass().getName()));\n\t}\n}\n","sourceCodeStart":72,"sourceCodeEnd":95,"githubUrl":"https://github.com/junit-team/junit5/blob/f070c699a08b5d8393df9afd147af5c5e90bb21b/junit-jupiter-params/src/main/java/org/junit/jupiter/params/converter/ArgumentConverter.java#L72-L95","documentation":"Thrown by the default method ArgumentConverter.convert(Object, FieldContext) when a custom ArgumentConverter implementation is used via @ConvertWith on a @Parameter-annotated field (not a method parameter) but the converter does not override the FieldContext-based overload. This overload was added in JUnit 5.13 (API status EXPERIMENTAL, since 6.0) to support field-level conversion in @ParameterizedClass. The %s placeholder is filled with the converter's actual class name.","triggerScenarios":"Implement ArgumentConverter and use it with @ConvertWith on a @Parameter field in a @ParameterizedClass, but only override the older convert(Object, ParameterContext) method. The framework calls the FieldContext overload for field-based conversion, hits the default, and throws.","commonSituations":"Existing custom ArgumentConverter implementations written before JUnit 5.13 being reused with @ParameterizedClass field-level @Parameter annotations after upgrading JUnit. Developers extending SimpleArgumentConverter (which only needs target type) and expecting it to work for fields without realizing the FieldContext path requires explicit implementation.","solutions":["Override the convert(Object source, FieldContext context) method in your ArgumentConverter implementation","If the conversion logic is the same regardless of context, delegate from the FieldContext overload to your existing convert logic","Alternatively, extend SimpleArgumentConverter or TypedArgumentConverter which handle the context delegation internally","If you don't need field-level conversion, use the converter only on method parameters"],"exampleFix":"// before — only overrides ParameterContext variant\npublic class MyConverter implements ArgumentConverter {\n    @Override\n    public Object convert(Object source, ParameterContext context) {\n        return convertValue(source);\n    }\n}\n\n// after — also override FieldContext variant\npublic class MyConverter implements ArgumentConverter {\n    @Override\n    public Object convert(Object source, ParameterContext context) {\n        return convertValue(source);\n    }\n    @Override\n    public Object convert(Object source, FieldContext context) {\n        return convertValue(source);\n    }\n    private Object convertValue(Object source) { ... }\n}\n\n// OR — extend SimpleArgumentConverter for simpler cases\npublic class MyConverter extends SimpleArgumentConverter {\n    @Override\n    public Object convert(Object source, Class<?> targetType) { ... }\n}","handlingStrategy":"validation","validationCode":"// Check if an ArgumentConverter supports field-level conversion\nimport org.junit.jupiter.params.converter.ArgumentConverter;\n\nstatic boolean isFieldOverloadOverridden(Class<? extends ArgumentConverter> convClass) {\n    try {\n        var m = convClass.getMethod(\"convert\",\n            Object.class,\n            org.junit.jupiter.params.support.FieldContext.class);\n        return m.getDeclaringClass() != ArgumentConverter.class;\n    } catch (NoSuchMethodException e) { return false; }\n}\n\n// Usage: if (!isFieldOverloadOverridden(MyConverter.class)) { /* warn or restrict to method params */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When upgrading to JUnit 5.13+, audit all custom ArgumentConverter implementations and add the FieldContext overload if used with @Parameter fields","Prefer extending SimpleArgumentConverter or TypedArgumentConverter which handle both context variants internally","Run a quick smoke test on every converter with a @ParameterizedClass field to catch missing overloads"],"tags":["converter","field-context","spi","version-compatibility","junit-params"],"backgroundTag":null,"analyzedSha":"f070c699a08b5d8393df9afd147af5c5e90bb21b","analyzedAt":"2026-08-11T20:31:00.530Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}