{"record":{"id":"84d1256510394ced","repo":"bumptech/glide","slug":"glidetype-methods-should-return-a-requestbuilder","errorCode":null,"errorMessage":"@GlideType methods should return a RequestBuilder<{}> object, but {} returns: {}. If you're using old style @GlideType methods, your method may have a void return type, but doing so is deprecated and support will be removed in a future version","messagePattern":"@GlideType methods should return a RequestBuilder<(.+?)> object, but (.+?) returns: (.+?)\\. If you're using old style @GlideType methods, your method may have a void return type, but doing so is deprecated and support will be removed in a future version","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java","lineNumber":228,"sourceCode":"      }\n    }\n    return true;\n  }\n\n  private static List<TypeMirror> getComparableParameterTypes(\n      ExecutableElement element, boolean skipFirst) {\n    return element.getParameters().stream()\n        .skip(skipFirst ? 1 : 0)\n        .map(VariableElement::asType)\n        .toList();\n  }\n\n  private void validateGlideType(ExecutableElement executableElement) {\n    TypeMirror returnType = executableElement.getReturnType();\n    validateGlideTypeAnnotations(executableElement);\n    if (!isRequestBuilder(returnType) || !typeMatchesExpected(returnType, executableElement)) {\n      String expectedClassName = getGlideTypeValue(executableElement);\n      throw new IllegalArgumentException(\n          \"@GlideType methods should return a RequestBuilder<\"\n              + expectedClassName\n              + \"> object, but \"\n              + getQualifiedMethodName(executableElement)\n              + \" returns: \"\n              + returnType\n              + \". If you're using old style @GlideType methods, your\"\n              + \" method may have a void return type, but doing so is deprecated and support will\"\n              + \" be removed in a future version\");\n    }\n    validateGlideTypeParameters(executableElement);\n  }\n\n  private String getGlideTypeValue(ExecutableElement executableElement) {\n    return processorUtil\n        .findClassValuesFromAnnotationOnClassAsNames(executableElement, GlideType.class)\n        .iterator()\n        .next();","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java#L210-L246","documentation":"@GlideType methods add RequestManager entry points (e.g. `GlideApp.asGif()`). They must return RequestBuilder<T> where T equals the Class<?> in the annotation's `value()`. validateGlideType checks both isRequestBuilder(returnType) and typeMatchesExpected(returnType, executableElement); failing either throws with the expected class and the actual return type.","triggerScenarios":"GlideExtensionValidator.validateGlideType reads `returnType = executableElement.getReturnType()` and `expectedClassName = getGlideTypeValue(executableElement)`; throws when `!isRequestBuilder(returnType) || !typeMatchesExpected(returnType, executableElement)`. Hit by returning void, RequestOptions, Drawable, or a RequestBuilder whose generic does not match `value()` (e.g. `@GlideType(GifDrawable.class)` returning `RequestBuilder<Bitmap>`).","commonSituations":"Mismatch between the `value()` class and the RequestBuilder generic; using the deprecated void style; returning the bare RequestBuilder without a type parameter; copy-pasting a @GlideType method and forgetting to update `value()`.","solutions":["Match the return type exactly to the annotation: `@GlideType(GifDrawable.class) public static RequestBuilder<GifDrawable> asGif(RequestBuilder<GifDrawable> requestBuilder) { ... }`.","Ensure the generic parameter of the returned RequestBuilder equals `value()`.","Migrate any deprecated void-style @GlideType method to the returning style."],"exampleFix":"// before\n@GlideType(GifDrawable.class)\npublic static RequestBuilder<Bitmap> asGif(RequestBuilder<GifDrawable> requestBuilder) {\n  return requestBuilder;\n}\n\n// after\n@GlideType(GifDrawable.class)\npublic static RequestBuilder<GifDrawable> asGif(RequestBuilder<GifDrawable> requestBuilder) {\n  return requestBuilder;\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Let the compiler enforce the return/param type match via generics.\n@GlideType(com.bumptech.glide.load.resource.gif.GifDrawable.class)\npublic static com.bumptech.glide.RequestBuilder<com.bumptech.glide.load.resource.gif.GifDrawable>\n    asGif(com.bumptech.glide.RequestBuilder<com.bumptech.glide.load.resource.gif.GifDrawable> requestBuilder) {\n  return requestBuilder;\n}","tryCatchPattern":null,"preventionTips":["Mirror the annotation `value()` Class exactly in the RequestBuilder<T> generic for both the return type and the parameter.","Use copy-paste of a known-good @GlideType method as your template."],"tags":["glide","annotation-processing","glidetype","return-type"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}