{"record":{"id":"497bf14787c002a6","repo":"bumptech/glide","slug":"multitransformation-must-contain-at-least-one-tran","errorCode":null,"errorMessage":"MultiTransformation must contain at least one Transformation","messagePattern":"MultiTransformation must contain at least one Transformation","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/bumptech/glide/load/MultiTransformation.java","lineNumber":22,"sourceCode":"import androidx.annotation.NonNull;\nimport com.bumptech.glide.load.engine.Resource;\nimport java.security.MessageDigest;\nimport java.util.Arrays;\nimport java.util.Collection;\n\n/**\n * A transformation that applies one or more transformations in iteration order to a resource.\n *\n * @param <T> The type of {@link com.bumptech.glide.load.engine.Resource} that will be transformed.\n */\npublic class MultiTransformation<T> implements Transformation<T> {\n  private final Collection<? extends Transformation<T>> transformations;\n\n  @SafeVarargs\n  @SuppressWarnings(\"varargs\")\n  public MultiTransformation(@NonNull Transformation<T>... transformations) {\n    if (transformations.length == 0) {\n      throw new IllegalArgumentException(\n          \"MultiTransformation must contain at least one Transformation\");\n    }\n    this.transformations = Arrays.asList(transformations);\n  }\n\n  public MultiTransformation(@NonNull Collection<? extends Transformation<T>> transformationList) {\n    if (transformationList.isEmpty()) {\n      throw new IllegalArgumentException(\n          \"MultiTransformation must contain at least one Transformation\");\n    }\n    this.transformations = transformationList;\n  }\n\n  @NonNull\n  @Override\n  public Resource<T> transform(\n      @NonNull Context context, @NonNull Resource<T> resource, int outWidth, int outHeight) {\n    Resource<T> previous = resource;","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/library/src/main/java/com/bumptech/glide/load/MultiTransformation.java#L4-L40","documentation":"MultiTransformation applies a chain of Transformation objects to a resource in iteration order. The varargs constructor requires at least one Transformation; an empty argument list produces a useless object that would skip all transformation logic. The IllegalArgumentException is thrown when transformations.length is 0.","triggerScenarios":"Calling new MultiTransformation<>() with no arguments. Spreading a programmatically-built array of transformations that happens to be empty. Passing a varargs collection that was filtered down to zero elements.","commonSituations":"Dynamic transformation pipelines built from user-selected options where no option is selected. Code that collects transformations from a list and passes them via varargs without checking emptiness.","solutions":["Check that the transformations array is non-empty before constructing MultiTransformation","If the collection might be empty, skip applying MultiTransformation entirely or provide a default Transformation","Use the Collection overload and validate before constructing"],"exampleFix":"// before\nMultiTransformation<Bitmap> multi = new MultiTransformation<>(transforms.toArray(new Transformation[0]));\n// after\nif (transforms.isEmpty()) {\n  // skip or use single transform\n} else {\n  MultiTransformation<Bitmap> multi = new MultiTransformation<>(transforms.toArray(new Transformation[0]));\n}","handlingStrategy":"validation","validationCode":"List<Transformation<Bitmap>> transforms = collectTransforms();\nif (!transforms.isEmpty()) {\n  Transformation<Bitmap>[] arr = transforms.toArray(new Transformation[0]);\n  options.transform(new MultiTransformation<>(arr));\n} else {\n  // no transforms to apply — skip MultiTransformation\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check that your transformations array is non-empty before constructing MultiTransformation","Default to a single CenterCrop or similar when no user-selected transforms exist","Prefer the Collection constructor for dynamic transform lists"],"tags":["glide","transformation","validation","varargs"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}