{"record":{"id":"885810e237974c26","repo":"microg/GmsCore","slug":"task-is-not-yet-completed","errorCode":null,"errorMessage":"Task is not yet completed","messagePattern":"Task is not yet completed","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"play-services-tasks/src/main/java/com/google/android/gms/tasks/DuplicateTaskCompletionException.java","lineNumber":29,"sourceCode":"import org.microg.gms.common.PublicApi;\n\n/**\n * An exception indicating that something attempted to set a result, exception, or cancellation on a {@link Task} that was already completed.\n */\n@PublicApi\npublic class DuplicateTaskCompletionException extends IllegalStateException {\n\n    private DuplicateTaskCompletionException(String s) {\n        super(s);\n    }\n\n    /**\n     * Creates a DuplicateTaskCompletionException from a {@link Task}.\n     *\n     * The {@link Task} must be complete.\n     */\n    public static DuplicateTaskCompletionException of(Task<?> task) {\n        if (!task.isComplete()) throw new IllegalStateException(\"Task is not yet completed\");\n        return new DuplicateTaskCompletionException(\"Task is already completed\");\n    }\n}\n","sourceCodeStart":11,"sourceCodeEnd":33,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-tasks/src/main/java/com/google/android/gms/tasks/DuplicateTaskCompletionException.java#L11-L33","documentation":"DuplicateTaskCompletionException.of(task) is a factory that builds the exception describing a Task that was completed more than once. It defensively throws IllegalStateException 'Task is not yet completed' when the passed Task is not complete, since a duplicate-completion report only makes sense for an already-completed Task.","triggerScenarios":"Invoking DuplicateTaskCompletionException.of(task) with a Task whose isComplete() returns false — i.e. calling it from code that tries to complete a Task but the Task instance passed in is actually still pending.","commonSituations":"Custom Task completion logic (e.g. TaskCompletionSource wrappers) that reports duplicate completion without first checking task.isComplete(); passing the wrong (pending) Task to the factory.","solutions":["Only call of(task) after confirming task.isComplete() returns true","Check that you are passing the Task being completed, not a different pending Task","Restructure completion code to guard: if (!task.isComplete()) don't report duplicate completion"],"exampleFix":"// before\nthrow DuplicateTaskCompletionException.of(pendingTask); // throws IllegalStateException\n// after\nif (task.isComplete()) {\n    throw DuplicateTaskCompletionException.of(task);\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// guard before calling the factory\nif (!task.isComplete()) {\n    return; // not a duplicate completion; skip reporting\n}","tryCatchPattern":"try {\n    throw DuplicateTaskCompletionException.of(task);\n} catch (IllegalStateException e) {\n    // task was not actually complete; wrong Task passed\n}","preventionTips":["Only invoke DuplicateTaskCompletionException.of on tasks where isComplete() is true","Verify you pass the same Task instance that the completion path targets","Unit-test TaskCompletionSource wrappers for both complete and pending paths"],"tags":["tasks","task-lifecycle","illegal-state"],"backgroundTag":"invalid-state-transition","analyzedSha":"157c9d86ac46c195a86c2f15ab55c84036223f95","analyzedAt":"2026-09-06T17:27:33.892Z","contentChangedAt":"2026-09-06T17:27:33.892Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}