{"record":{"id":"9a65ac81c8e5a0ba","repo":"bumptech/glide","slug":"given-both-modules-and-extensions-expected-one-or","errorCode":null,"errorMessage":"Given both modules and extensions, expected one or the other. Modules: {} Extensions: {}","messagePattern":"Given both modules and extensions, expected one or the other\\. Modules: (.+?) Extensions: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/IndexerGenerator.java","lineNumber":71,"sourceCode":"\n  IndexerGenerator(ProcessorUtil processorUtil) {\n    this.processorUtil = processorUtil;\n  }\n\n  TypeSpec generate(List<TypeElement> types) {\n    List<TypeElement> modules = new ArrayList<>();\n    List<TypeElement> extensions = new ArrayList<>();\n    for (TypeElement element : types) {\n      if (processorUtil.isExtension(element)) {\n        extensions.add(element);\n      } else if (processorUtil.isLibraryGlideModule(element)) {\n        modules.add(element);\n      } else {\n        throw new IllegalArgumentException(\"Unrecognized type: \" + element);\n      }\n    }\n    if (!modules.isEmpty() && !extensions.isEmpty()) {\n      throw new IllegalArgumentException(\n          \"Given both modules and extensions, expected one or the \"\n              + \"other. Modules: \"\n              + modules\n              + \" Extensions: \"\n              + extensions);\n    }\n    if (!modules.isEmpty()) {\n      return generate(types, GlideModule.class);\n    } else {\n      return generate(types, GlideExtension.class);\n    }\n  }\n\n  private TypeSpec generate(\n      List<TypeElement> libraryModules, Class<? extends Annotation> annotation) {\n    // Sort modules by qualified name to ensure deterministic ordering\n    List<TypeElement> sortedModules = new ArrayList<>(libraryModules);\n    sortedModules.sort(Comparator.comparing(a -> a.getQualifiedName().toString()));","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/IndexerGenerator.java#L53-L89","documentation":"Each generated Indexer class bundles either modules OR extensions, never both, because they are indexed separately downstream. IndexerGenerator.generate throws when, after classification, both the `modules` and `extensions` lists are non-empty for the same indexer batch — an internal invariant violation indicating mixed classification input.","triggerScenarios":"IndexerGenerator.generate: `if (!modules.isEmpty() && !extensions.isEmpty()) throw`. Reached only if the same batch contains elements classified as both a LibraryGlideModule and a GlideExtension — which should not happen for well-formed classes (a class cannot validly be both).","commonSituations":"A class that somehow has both @GlideExtension and extends LibraryGlideModule (or is detected as both); a custom/buggy annotation setup; incremental cache feeding a mixed batch; an upstream Glide bug.","solutions":["Inspect the printed modules/extensions lists and ensure no class is both a LibraryGlideModule and a @GlideExtension — split them.","Clean and rebuild to rule out stale indexer inputs.","Align Glide dependency versions across modules."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never make a single class both a LibraryGlideModule and a @GlideExtension.","Keep library modules and extensions in separate classes.","Clean and align Glide versions if the error appears without an obvious cause."],"tags":["glide","annotation-processing","indexer","internal"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}