didi/DoKit · error · IllegalArgumentException

Priority invalid.

Error message

Priority invalid.

What it means

Thrown by Request.Builder.priority(Priority) when the argument is null. Priority must be one of the enum constants (LOW, NORMAL, HIGH, IMMEDIATE); a null priority cannot be ordered in Picasso's request queue, so it fails fast with IllegalArgumentException.

Source

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

    /** Clear the rotation transformation, if any. */
    public Builder clearRotation() {
      rotationDegrees = 0;
      rotationPivotX = 0;
      rotationPivotY = 0;
      hasRotationPivot = false;
      return this;
    }

    /** Decode the image using the specified config. */
    public Builder config(Bitmap.Config config) {
      this.config = config;
      return this;
    }

    /** Execute request using the specified priority. */
    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) {

View on GitHub (pinned to 626827cddb)

Solutions

  1. Default before calling: priority(p != null ? p : Priority.NORMAL).
  2. Use Priority.NORMAL as the default value when parsing optional priority fields.
  3. Annotate the parameter @NonNull in your wrapper so static analysis catches null flows.

Example fix

// before
Priority p = config.priority; // null when absent
builder.priority(p);

// after
Priority p = config.priority != null ? config.priority : Priority.NORMAL;
builder.priority(p);
Defensive patterns

Strategy: type-guard

Validate before calling

if (priority != null) { builder.priority(priority); } else { builder.priority(Priority.NORMAL); }

Type guard

static Priority safePriority(Priority p) {
  return p != null ? p : Priority.NORMAL;
}

Prevention

When it happens

Trigger: Passing a Priority variable that is null: priority(null), or priority(config.getPriority()) where config has no priority set.

Common situations: Mapping an optional priority from remote config / JSON where the field is absent and decodes to null; passing a priority looked up from a Map that misses; refactoring a method signature so null reaches this setter.

Related errors


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