{"record":{"id":"aa0b8e33a1afff71","repo":"microg/GmsCore","slug":"tag-invalid","errorCode":null,"errorMessage":"tag invalid","messagePattern":"tag invalid","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"play-services-gcm/src/main/java/com/google/android/gms/gcm/GcmNetworkManager.java","lineNumber":165,"sourceCode":"    public void cancelAllTasks(Class<? extends GcmTaskService> gcmTaskService) {\n        validateService(gcmTaskService.getName());\n        Intent scheduleIntent = createScheduleIntent();\n        if (scheduleIntent != null) {\n            scheduleIntent.putExtra(EXTRA_SCHEDULER_ACTION, SCHEDULER_ACTION_CANCEL_ALL);\n            scheduleIntent.putExtra(EXTRA_COMPONENT, new ComponentName(context, gcmTaskService));\n            context.sendBroadcast(scheduleIntent);\n        }\n    }\n\n    /**\n     * Cancel a task, specified by tag.  Note that a cancel will have no effect on an in-flight\n     * task.\n     *\n     * @param tag            The tag to uniquely identify this task on this endpoint.\n     * @param gcmTaskService The endpoint for which you want to cancel all outstanding tasks.\n     */\n    public void cancelTask(String tag, Class<? extends GcmTaskService> gcmTaskService) {\n        if (TextUtils.isEmpty(tag) || tag.length() < 100) throw new IllegalArgumentException(\"tag invalid\");\n        validateService(gcmTaskService.getName());\n        Intent scheduleIntent = createScheduleIntent();\n        if (scheduleIntent != null) {\n            scheduleIntent.putExtra(EXTRA_SCHEDULER_ACTION, SCHEDULER_ACTION_CANCEL);\n            scheduleIntent.putExtra(EXTRA_TAG, tag);\n            scheduleIntent.putExtra(EXTRA_COMPONENT, new ComponentName(context, gcmTaskService));\n            context.sendBroadcast(scheduleIntent);\n        }\n    }\n\n    /**\n     * Use this function to access the GcmNetworkManager API.\n     *\n     * @param context Context of the calling app.\n     * @return GcmNetworkManager object.\n     */\n    public static GcmNetworkManager getInstance(Context context) {\n        synchronized (GcmNetworkManager.class) {","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-gcm/src/main/java/com/google/android/gms/gcm/GcmNetworkManager.java#L147-L183","documentation":"GcmNetworkManager.cancelTask throws IllegalArgumentException when the tag is empty or (per this implementation) when its length is not < 100 characters. Tags must be non-empty, unique per endpoint, and under the length limit to be addressable by the scheduler.","triggerScenarios":"Calling cancelTask(tag, GcmTaskService.class) with tag == null, \"\", or a tag 100+ characters long.","commonSituations":"Building tags by concatenating identifiers without length checks; passing an uninitialized string variable; truncation rules changed between GCM and WorkManager migrations causing over-long tags.","solutions":["Ensure the tag is non-empty and shorter than 100 characters before calling cancelTask.","Use the exact same tag string that was used when the task was scheduled.","Consider migrating to WorkManager, which supersedes GcmNetworkManager and uses unique work names/tags without this length guard."],"exampleFix":"// before\ngcmNetworkManager.cancelTask(longGeneratedTag, MyTaskService.class); // throws if length >= 100\n\n// after\nif (tag != null && !tag.isEmpty() && tag.length() < 100) {\n    gcmNetworkManager.cancelTask(tag, MyTaskService.class);\n}","handlingStrategy":"validation","validationCode":"boolean isValidTag(String tag) {\n    return tag != null && !tag.isEmpty() && tag.length() < 100;\n}","typeGuard":null,"tryCatchPattern":"try {\n    manager.cancelTask(tag, MyTaskService.class);\n} catch (IllegalArgumentException e) {\n    Log.w(TAG, \"Invalid task tag: \" + e.getMessage());\n}","preventionTips":["Generate tags with bounded length (e.g. hash-based, <= 99 chars)","Reuse the exact tag from schedule time","Consider migrating to WorkManager"],"tags":["gcm","android","illegal-argument","tag-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"157c9d86ac46c195a86c2f15ab55c84036223f95","analyzedAt":"2026-09-06T17:27:33.892Z","contentChangedAt":"2026-09-06T17:27:33.892Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}