didi/DoKit · error · IllegalArgumentException
Tag invalid.
Error message
Tag invalid.
What it means
Thrown by RequestCreator.tag(Object) when null is passed. Tags are the identity used to cancel, pause, and resume groups of requests (DokitPicasso.cancelTag/pauseTag/resumeTag), so a null tag has no meaning and is rejected with IllegalArgumentException.
Source
Thrown at Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java:189
* related requests that can be managed together e.g. paused, resumed,
* or canceled.
* <p>
* You can either use simple {@link String} tags or objects that naturally
* define the scope of your requests within your app such as a
* {@link android.content.Context}, an {@link android.app.Activity}, or a
* {@link android.app.Fragment}.
*
* <strong>WARNING:</strong>: Picasso will keep a reference to the tag for
* as long as this tag is paused and/or has active requests. Look out for
* potential leaks.
*
* @see DokitPicasso#cancelTag(Object)
* @see DokitPicasso#pauseTag(Object)
* @see DokitPicasso#resumeTag(Object)
*/
public RequestCreator tag(Object tag) {
if (tag == null) {
throw new IllegalArgumentException("Tag invalid.");
}
if (this.tag != null) {
throw new IllegalStateException("Tag already set.");
}
this.tag = tag;
return this;
}
/**
* Attempt to resize the image to fit exactly into the target {@link ImageView}'s bounds. This
* will result in delayed execution of the request until the {@link ImageView} has been laid out.
* <p>
* <em>Note:</em> This method works only when your target is an {@link ImageView}.
*/
public RequestCreator fit() {
deferred = true;
return this;
}View on GitHub (pinned to 626827cddb)
Solutions
- Pass a non-null, stable object as the tag (e.g. the Activity instance, a String constant, or the Fragment)
- If the tag source may be null, guard: if (tag != null) builder.tag(tag);
- To stop requests, call picasso.cancelTag(existingTag) instead of trying to null the tag
Example fix
// before
Object tag = getIntent().getSerializableExtra("tag"); // may be null
picasso.load(url).tag(tag).into(imageView); // throws "Tag invalid."
// after
Object tag = getIntent().getSerializableExtra("tag");
RequestCreator rc = picasso.load(url);
if (tag != null) rc.tag(tag);
rc.into(imageView); Defensive patterns
Strategy: validation
Validate before calling
Object requestTag = getActivity(); // or a String constant
if (requestTag != null) {
rc.tag(requestTag);
} Type guard
static Object requireTag(Object tag) {
if (tag == null) throw new IllegalArgumentException("Tag required");
return tag;
} Prevention
- Use constants or lifecycle-stable objects (Activity instance) as tags, never nullable extras
- There is no way to clear a tag with null — call picasso.cancelTag(tag) instead
- Set the tag before into()/fetch()/get(); the guard throws on any later misuse
When it happens
Trigger: Calling .tag(null), or passing a tag variable that was never assigned (e.g. a null String tag from an intent extra or a nullable activity tag).
Common situations: Using tag(getActivity()) in fragments where getContext()/getActivity() is null during detach; passing a tag read from a Bundle/Intent that did not contain it; forgetting that tag must be set before into() and attempting to 'reset' it with null.
Related errors
- Error image may not be null.
- Tag already set.
- Memory policy cannot be null.
- Network policy cannot be null.
- Target must not be null.
AI-assisted analysis of didi/DoKit@626827cddb (2026-08-14).
Data as JSON: /api/errors/bea9e8e1e67b9cb1.
Report an issue: GitHub.