{"record":{"id":"77612c7b54d6ec09","repo":"bumptech/glide","slug":"glideoption-methods-should-return-a-baserequestop","errorCode":null,"errorMessage":"@GlideOption methods should return a BaseRequestOptions<?> object, but {} returns {}. If you're using old style @GlideOption methods, your method may have a void return type, but doing so is deprecated and support will be removed in a future version","messagePattern":"@GlideOption methods should return a BaseRequestOptions<\\?> object, but (.+?) returns (.+?)\\. If you're using old style @GlideOption 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":101,"sourceCode":"          \"RequestOptionsExtensions must be public, with private constructors and only static\"\n              + \" methods. Found a non-private constructor in: \"\n              + getEnclosingClassName(element));\n    }\n    ExecutableElement executableElement = (ExecutableElement) element;\n    if (!executableElement.getParameters().isEmpty()) {\n      throw new IllegalArgumentException(\n          \"RequestOptionsExtensions must be public, with private constructors and only static\"\n              + \" methods. Found parameters in the constructor of: \"\n              + getEnclosingClassName(element));\n    }\n  }\n\n  private void validateGlideOption(ExecutableElement executableElement) {\n    validateGlideOptionAnnotations(executableElement);\n    validateGlideOptionParameters(executableElement);\n    TypeMirror returnType = executableElement.getReturnType();\n    if (!isBaseRequestOptions(returnType)) {\n      throw new IllegalArgumentException(\n          \"@GlideOption methods should return a\"\n              + \" BaseRequestOptions<?> object, but \"\n              + getQualifiedMethodName(executableElement)\n              + \" returns \"\n              + returnType\n              + \". If you're using old style @GlideOption 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    validateGlideOptionOverride(executableElement);\n  }\n\n  private void validateGlideOptionAnnotations(ExecutableElement executableElement) {\n    validateAnnotatedNonNull(executableElement);\n  }\n\n  private void validateGlideOptionParameters(ExecutableElement executableElement) {\n    if (executableElement.getParameters().isEmpty()) {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java#L83-L119","documentation":"@GlideOption methods must return a BaseRequestOptions<?> (RequestOptions is the concrete subclass generated code chains on). Returning anything else — String, void (the deprecated old style), Integer, etc. — breaks the generated fluent API. validateGlideOption checks isBaseRequestOptions(returnType) and includes the actual return type plus the deprecated-void note in the message.","triggerScenarios":"GlideExtensionValidator.validateGlideOption reads executableElement.getReturnType(); if it is not assignable to com.bumptech.glide.request.BaseRequestOptions<?> (legacy string compare or erased-element compare per useLegacyTypeComparison), it throws. Hit by returning `void`, `String`, `Drawable`, or a custom type from a @GlideOption method.","commonSituations":"Porting old Glide v3 void-style options to the new API but forgetting to `return options`; chaining helpers that accidentally return a sub-result (`options.transform()` whose generic is fine, but returning a builder of a different type); returning `RequestBuilder` instead of `RequestOptions`.","solutions":["Change the @GlideOption method to return RequestOptions (or its generated GlideOptions) and end with `return options;`.","Ensure the chain on `options` returns the same RequestOptions instance — `return options.centerCrop().placeholder(R.drawable.foo);`.","If you intended the deprecated void style, be aware it is no longer supported in this version; migrate to the returning style."],"exampleFix":"// before\n@GlideOption\npublic static void cache(RequestOptions options) {\n  options.diskCacheStrategy(DiskCacheStrategy.ALL);\n}\n\n// after\n@GlideOption\npublic static RequestOptions cache(RequestOptions options) {\n  return options.diskCacheStrategy(DiskCacheStrategy.ALL);\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Compile-time type safety: declare the method signature to return RequestOptions.\n// The Kotlin/Java compiler then guarantees a BaseRequestOptions<?> return.\n@GlideOption\npublic static RequestOptions myOption(RequestOptions options) {\n  return options.centerCrop(); // same type, no accidental void/foreign return\n}","tryCatchPattern":null,"preventionTips":["Always `return options;` (the same instance, chained) at the end of a @GlideOption method.","Declare the return type as RequestOptions so the compiler rejects void/foreign returns.","Migrate any legacy void-style options to the returning style."],"tags":["glide","annotation-processing","glideoption","return-type"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}