didi/DoKit · error · IllegalArgumentException

Transformation must not be null.

Error message

Transformation must not be null.

What it means

Thrown by Request.Builder.transform(Transformation) when the argument is null. Transformations are applied to the decoded bitmap and must be concrete objects, so Picasso rejects null immediately rather than failing later during bitmap processing.

Source

Thrown at Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/Request.java:427

    public Builder priority(Priority priority) {
      if (priority == null) {
        throw new IllegalArgumentException("Priority invalid.");
      }
      if (this.priority != null) {
        throw new IllegalStateException("Priority already set.");
      }
      this.priority = priority;
      return this;
    }

    /**
     * Add a custom transformation to be applied to the image.
     * <p>
     * Custom transformations will always be run after the built-in transformations.
     */
    public Builder transform(com.didichuxing.doraemonkit.picasso.Transformation transformation) {
      if (transformation == null) {
        throw new IllegalArgumentException("Transformation must not be null.");
      }
      if (transformation.key() == null) {
        throw new IllegalArgumentException("Transformation key must not be null.");
      }
      if (transformations == null) {
        transformations = new ArrayList<com.didichuxing.doraemonkit.picasso.Transformation>(2);
      }
      transformations.add(transformation);
      return this;
    }

    /**
     * Add a list of custom transformations to be applied to the image.
     * <p>
     * Custom transformations will always be run after the built-in transformations.
     */
    public Builder transform(List<? extends Transformation> transformations) {
      if (transformations == null) {

View on GitHub (pinned to 626827cddb)

Solutions

  1. Null-check before calling transform; skip null entries.
  2. Make transformation factory methods return a no-op Transformation instead of null.
  3. Filter nulls from lists: list.stream().filter(Objects::nonNull) before use.

Example fix

// before
Transformation t = imageType.isCircle() ? new CircleTransform() : null;
builder.transform(t);

// after
if (imageType.isCircle()) {
  builder.transform(new CircleTransform());
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (transformation != null) { builder.transform(transformation); }

Type guard

static boolean isUsableTransformation(Transformation t) {
  return t != null && t.key() != null;
}

Prevention

When it happens

Trigger: Calling transform(null), or transform(transformations.get(i)) where the list contains a null element.

Common situations: Conditionally building a transformation list with null placeholders; a factory method that returns null for unsupported image types and is passed straight through; iterating a sparse list with unset slots.

Related errors


AI-assisted analysis of didi/DoKit@626827cddb (2026-08-14). Data as JSON: /api/errors/6d4662ab1a70441d. Report an issue: GitHub.