{"record":{"id":"f96c66ce43e52d4c","repo":"microg/GmsCore","slug":"category-for-sessionprovider-must-not-be-null-or-e","errorCode":null,"errorMessage":"Category for SessionProvider must not be null or empty string.","messagePattern":"Category for SessionProvider must not be null or empty string\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"play-services-cast-framework/src/main/java/com/google/android/gms/cast/framework/CastContext.java","lineNumber":164,"sourceCode":"            this.delegate = CastDynamiteModule.newCastContext(appContext, castOptions, mediaRouter, getSessionProviderMap());\n            this.sessionManager = new SessionManager(appContext, delegate.getSessionManagerImpl());\n            this.discoveryManager = new DiscoveryManager(appContext, delegate.getDiscoveryManagerImpl());\n        } catch (RemoteException e) {\n            throw new IllegalStateException(\"Failed to call dynamite module\", e);\n        }\n    }\n\n    private Map<String, IBinder> getSessionProviderMap() {\n        Map<String, IBinder> map = new HashMap<>();\n        if (castSessionProvider != null) {\n            map.put(castSessionProvider.getCategory(), castSessionProvider.asBinder());\n        }\n        List<SessionProvider> list = this.additionalSessionProviders;\n        if (list != null) {\n            for (SessionProvider sessionProvider : list) {\n                if (sessionProvider == null) throw new IllegalArgumentException(\"Additional SessionProvider must not be null.\");\n                if (sessionProvider.getCategory() == null || sessionProvider.getCategory().isEmpty())\n                    throw new IllegalArgumentException(\"Category for SessionProvider must not be null or empty string.\");\n                if (map.containsKey(sessionProvider.getCategory()))\n                    throw new IllegalArgumentException(\"SessionProvider for category \" + sessionProvider.getCategory() + \" already added\");\n                map.put(sessionProvider.getCategory(), sessionProvider.asBinder());\n            }\n        }\n        return map;\n    }\n\n    private static OptionsProvider getOptionsProvider(Context context) {\n        try {\n            Bundle metaData = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA).metaData;\n            String optionsProviderClassName = metaData.getString(OPTIONS_PROVIDER_CLASS_NAME_KEY);\n            if (optionsProviderClassName != null) {\n                return Class.forName(optionsProviderClassName).asSubclass(OptionsProvider.class).getDeclaredConstructor().newInstance();\n            }\n            throw new IllegalStateException(\"The fully qualified name of the implementation of OptionsProvider must be provided as a metadata in the AndroidManifest.xml with key com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME.\");\n        } catch (PackageManager.NameNotFoundException | ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InstantiationException |\n                 InvocationTargetException | NullPointerException e) {","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-cast-framework/src/main/java/com/google/android/gms/cast/framework/CastContext.java#L146-L182","documentation":"Validation in CastContext.getSessionProviderMap: a SessionProvider's getCategory() returned null or an empty string, so it cannot be used as a map key. The provider with the unusable category is the input at fault.","triggerScenarios":"Thrown at play-services-cast-framework/src/main/java/com/google/android/gms/cast/framework/CastContext.java:164 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Override SessionProvider.getCategory() to return a non-empty unique category string","Drop providers whose category is unusable before constructing CastContext"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}