{"record":{"id":"528d0a0d68919d59","repo":"bumptech/glide","slug":"glideoption-methods-must-take-a-baserequestoption","errorCode":null,"errorMessage":"@GlideOption methods must take a BaseRequestOptions<?> object as their first parameter, but {} has none","messagePattern":"@GlideOption methods must take a BaseRequestOptions<\\?> object as their first parameter, but (.+?) has none","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java","lineNumber":120,"sourceCode":"          \"@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()) {\n      throw new IllegalArgumentException(\n          \"@GlideOption methods must take a \"\n              + \"BaseRequestOptions<?> object as their first parameter, but \"\n              + getQualifiedMethodName(executableElement)\n              + \" has none\");\n    }\n    VariableElement first = executableElement.getParameters().get(0);\n    TypeMirror expected = first.asType();\n    if (!isBaseRequestOptions(expected)) {\n      throw new IllegalArgumentException(\n          \"@GlideOption methods must take a\"\n              + \" BaseRequestOptions<?> object as their first parameter, but the first parameter\"\n              + \" in \"\n              + getQualifiedMethodName(executableElement)\n              + \" is \"\n              + expected);\n    }\n  }\n","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java#L102-L138","documentation":"Every @GlideOption method receives the RequestOptions instance it mutates as its first parameter, so Glide can pass the cloned/locked object through. validateGlideOptionParameters throws when executableElement.getParameters() is empty — there is no RequestOptions to operate on.","triggerScenarios":"GlideExtensionValidator.validateGlideOptionParameters: `if (executableElement.getParameters().isEmpty()) throw`. Hit by a no-arg @GlideOption method like `@GlideOption public static RequestOptions cache() { ... }`.","commonSituations":"Writing a factory-style helper (`@GlideOption public static RequestOptions noCache() { return new RequestOptions(); }`) instead of an instance-extending method; forgetting the leading RequestOptions parameter when copying an example.","solutions":["Add a leading parameter of type RequestOptions (or the generated RequestOptions subclass) to the method and operate on it.","Return that same instance after chaining: `public static RequestOptions cache(RequestOptions options) { return options.diskCacheStrategy(ALL); }`."],"exampleFix":"// before\n@GlideOption\npublic static RequestOptions noCache() {\n  return new RequestOptions().diskCacheStrategy(NONE);\n}\n\n// after\n@GlideOption\npublic static RequestOptions noCache(RequestOptions options) {\n  return options.diskCacheStrategy(DiskCacheStrategy.NONE);\n}","handlingStrategy":"validation","validationCode":"@Test void glideOptionMethodsHaveRequestOptionsFirstParam() throws Exception {\n  for (java.lang.reflect.Method m : MyGlideExtension.class.getDeclaredMethods()) {\n    if (m.isAnnotationPresent(com.bumptech.glide.annotation.GlideOption.class)) {\n      assertTrue(\"@GlideOption needs >=1 param: \" + m, m.getParameterCount() >= 1);\n      assertEquals(\"first param must be RequestOptions: \" + m,\n          com.bumptech.glide.request.RequestOptions.class, m.getParameterTypes()[0]);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always start @GlideOption methods with `RequestOptions options`.","Use a code template/IDE live template that pre-fills the RequestOptions first parameter."],"tags":["glide","annotation-processing","glideoption","parameters"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}