{"record":{"id":"1d74e7dcd46fd8cf","repo":"bumptech/glide","slug":"glideoption-methods-must-take-a-baserequestoption-1d74e7","errorCode":null,"errorMessage":"@GlideOption methods must take a BaseRequestOptions<?> object as their first parameter, but the first parameter in {} is {}","messagePattern":"@GlideOption methods must take a BaseRequestOptions<\\?> object as their first parameter, but the first parameter in (.+?) is (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java","lineNumber":129,"sourceCode":"    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\n  private boolean isBaseRequestOptions(TypeMirror typeMirror) {\n    if (useLegacyTypeComparison) {\n      return typeMirror.toString().equals(\"com.bumptech.glide.request.BaseRequestOptions<?>\");\n    }\n    return typeMirror instanceof DeclaredType declaredType\n        && declaredType.asElement() instanceof TypeElement typeElement\n        && typeElement\n            .getQualifiedName()\n            .contentEquals(\"com.bumptech.glide.request.BaseRequestOptions\");","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java#L111-L147","documentation":"The first parameter of a @GlideOption method must be a BaseRequestOptions<?> (so the generated code can pass through the RequestOptions being customized). validateGlideOptionParameters checks isBaseRequestOptions(expected) on the first parameter's type and rejects anything else (e.g. Context, String, Drawable), printing both the method and the offending type.","triggerScenarios":"GlideExtensionValidator.validateGlideOptionParameters reads the first VariableElement, takes its asType(), and if it is not BaseRequestOptions<?> throws. Hit by methods whose first parameter is e.g. `Context`, `int`, `Drawable`, or `RequestBuilder` (wrong base type).","commonSituations":"Mistakenly taking a RequestBuilder (that belongs to @GlideType) as the first parameter; passing a resource id or Drawable as the first parameter instead of RequestOptions; using a custom subclass not recognized as BaseRequestOptions due to legacy type comparison.","solutions":["Make the first parameter `RequestOptions options` (or the generated RequestOptions subclass) — the object the method extends.","Move any extra inputs (resource ids, Drawables) to subsequent parameters after the RequestOptions one.","If using a custom RequestOptions subclass, confirm the processor's BaseRequestOptions comparison recognizes it (prefer the standard RequestOptions)."],"exampleFix":"// before\n@GlideOption\npublic static RequestOptions avatar(RequestBuilder<?> builder, int placeholder) {\n  return builder.placeholder(placeholder);\n}\n\n// after\n@GlideOption\npublic static RequestOptions avatar(RequestOptions options, int placeholder) {\n  return options.placeholder(placeholder);\n}","handlingStrategy":"validation","validationCode":"@Test void glideOptionFirstParamIsRequestOptions() throws Exception {\n  for (java.lang.reflect.Method m : MyGlideExtension.class.getDeclaredMethods()) {\n    if (m.isAnnotationPresent(com.bumptech.glide.annotation.GlideOption.class)) {\n      Class<?> first = m.getParameterTypes()[0];\n      assertTrue(\"first param must be RequestOptions: \" + m + \" got \" + first,\n          com.bumptech.glide.request.BaseRequestOptions.class.isAssignableFrom(first));\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not reuse @GlideType/RequestBuilder signatures for @GlideOption methods.","Validate first-parameter types in a reflection test to catch copy-paste mistakes early."],"tags":["glide","annotation-processing","glideoption","parameters","return-type"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}