{"record":{"id":"bea9e8e1e67b9cb1","repo":"didi/DoKit","slug":"tag-invalid","errorCode":null,"errorMessage":"Tag invalid.","messagePattern":"Tag invalid\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java","lineNumber":189,"sourceCode":"     * related requests that can be managed together e.g. paused, resumed,\n     * or canceled.\n     * <p>\n     * You can either use simple {@link String} tags or objects that naturally\n     * define the scope of your requests within your app such as a\n     * {@link android.content.Context}, an {@link android.app.Activity}, or a\n     * {@link android.app.Fragment}.\n     *\n     * <strong>WARNING:</strong>: Picasso will keep a reference to the tag for\n     * as long as this tag is paused and/or has active requests. Look out for\n     * potential leaks.\n     *\n     * @see DokitPicasso#cancelTag(Object)\n     * @see DokitPicasso#pauseTag(Object)\n     * @see DokitPicasso#resumeTag(Object)\n     */\n    public RequestCreator tag(Object tag) {\n        if (tag == null) {\n            throw new IllegalArgumentException(\"Tag invalid.\");\n        }\n        if (this.tag != null) {\n            throw new IllegalStateException(\"Tag already set.\");\n        }\n        this.tag = tag;\n        return this;\n    }\n\n    /**\n     * Attempt to resize the image to fit exactly into the target {@link ImageView}'s bounds. This\n     * will result in delayed execution of the request until the {@link ImageView} has been laid out.\n     * <p>\n     * <em>Note:</em> This method works only when your target is an {@link ImageView}.\n     */\n    public RequestCreator fit() {\n        deferred = true;\n        return this;\n    }","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java#L171-L207","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nObject tag = getIntent().getSerializableExtra(\"tag\"); // may be null\npicasso.load(url).tag(tag).into(imageView); // throws \"Tag invalid.\"\n\n// after\nObject tag = getIntent().getSerializableExtra(\"tag\");\nRequestCreator rc = picasso.load(url);\nif (tag != null) rc.tag(tag);\nrc.into(imageView);","handlingStrategy":"validation","validationCode":"Object requestTag = getActivity(); // or a String constant\nif (requestTag != null) {\n    rc.tag(requestTag);\n}","typeGuard":"static Object requireTag(Object tag) {\n    if (tag == null) throw new IllegalArgumentException(\"Tag required\");\n    return tag;\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["picasso","dokit","android","image-loading","null-safety","request-tag"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}