{"record":{"id":"f127fbc0ee09dd89","repo":"didi/DoKit","slug":"tag-already-set","errorCode":null,"errorMessage":"Tag already set.","messagePattern":"Tag already set\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java","lineNumber":192,"sourceCode":"     * 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    }\n\n    /**\n     * Internal use only. Used by {@link DeferredRequestCreator}.","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java#L174-L210","documentation":"Thrown by RequestCreator.tag(Object) when a tag was already assigned on the same builder. A request belongs to exactly one tag group; a second tag() call would make cancel/pause/resume semantics ambiguous, so Picasso throws IllegalStateException.","triggerScenarios":"Calling .tag(tagA).tag(tagB) on the same RequestCreator, e.g. shared code sets a default tag and the call site adds another.","commonSituations":"Base activity/fragment helper classes that tag every request with the screen, combined with call sites adding their own tag; retry wrappers that re-apply a tag to a reused builder.","solutions":["Keep exactly one tag() call per chain — decide the owner of the tag (helper or call site)","Make the helper's tag conditional or pass the tag into the helper as a parameter","Start a fresh request chain instead of retagging an existing one"],"exampleFix":"// before\nRequestCreator rc = picasso.load(url).tag(\"screen\");\nrc.tag(\"feed-item-42\"); // throws \"Tag already set.\"\n\n// after\nRequestCreator rc = picasso.load(url).tag(\"feed-item-42\");","handlingStrategy":"validation","validationCode":"// Assign the tag exactly once, from one owner\nObject tag = (customTag != null) ? customTag : DEFAULT_TAG;\nrc.tag(tag);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One tag() call per chain; put it in a single helper and pass the tag in as a parameter","Do not let base classes and call sites both tag the same request","Retagging is impossible by design — build a new chain if ownership must change"],"tags":["picasso","dokit","android","image-loading","builder","request-tag"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}