{"record":{"id":"0d82de20eb10090a","repo":"Unity-Technologies/UnityCsReference","slug":"platform-guid-platformguid-is-not-a-valid-unity","errorCode":null,"errorMessage":"Platform GUID {platformGuid} is not a valid Unity build platform.","messagePattern":"Platform GUID (.+?) is not a valid Unity build platform\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/BuildProfile/BuildProfile.Create.cs","lineNumber":198,"sourceCode":"\n            // Notify the UI of creation so that the new build profile can be selected\n            onBuildProfileCreated?.Invoke(buildProfile);\n            return buildProfile;\n        }\n\n        /// <summary>\n        /// Validates that the platform GUID corresponds to a known Unity platform.\n        /// Does NOT check if the platform module is installed.\n        /// </summary>\n        static void ValidatePlatformExists(GUID platformGuid)\n        {\n            foreach (var guid in BuildTargetDiscovery.GetAllPlatforms())\n            {\n                if (guid == platformGuid)\n                    return;\n            }\n\n            throw new ArgumentException(\n                $\"Platform GUID {platformGuid} is not a valid Unity build platform.\");\n        }\n\n        /// <summary>\n        /// Validates if the provided path name length is supported by the Asset database.\n        /// Throws an ArgumentException if the platform is not valid.\n        /// </summary>\n        /// <param name=\"assetPath\">The path to the build profile to be created.</param>\n        static void ValidateFileNameLength(string assetPath)\n        {\n            var byteCount = System.Text.Encoding.UTF8.GetByteCount(Path.GetFileName(assetPath));\n            // File name length is limited by the asset database\n            if (byteCount > BuildProfileModuleUtil.k_MaxAssetFileNameLength)\n                throw new ArgumentException($\"Build profile name is too long ({byteCount}) - max supported is {BuildProfileModuleUtil.k_MaxAssetFileNameLength} bytes.\");\n        }\n\n        internal void NotifyBuildProfileExtensionOfCreation(int preconfiguredSettingsVariant)\n        {","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/BuildProfile/BuildProfile.Create.cs#L180-L216","documentation":"Thrown by ValidatePlatformExists(GUID) when the supplied platformGuid does not match any platform returned by BuildTargetDiscovery.GetAllPlatforms(). This is a stricter check than error 129: it verifies the GUID is a known Unity platform at all, regardless of whether it is installed. If the GUID is not in the full platform enumeration, the method throws ArgumentException.","triggerScenarios":"Passing a malformed, random, or outdated GUID as platformId to the profile creation flow. ValidatePlatformExists is called during creation and rejects unknown GUIDs before any module-installation check.","commonSituations":"Hardcoded GUID that became invalid after a Unity version change; copy/paste error in a platform GUID; passing a GUID obtained from an unrelated system; serialization corruption of the platform GUID field.","solutions":["Obtain the platform GUID from BuildTargetDiscovery.GetAllPlatforms() at runtime rather than hardcoding it.","Validate the GUID against GetAllPlatforms() before calling the create API.","If the GUID came from a saved profile, re-resolve it against the current Unity version's platform list."],"exampleFix":"// before\nBuildProfile.Create(myHardcodedGuid, name);\n\n// after\nvar valid = BuildTargetDiscovery.GetAllPlatforms().Any(g => g == myHardcodedGuid);\nif (!valid) throw new InvalidOperationException(\"GUID is not a known platform.\");\nBuildProfile.Create(myHardcodedGuid, name);","handlingStrategy":"validation","validationCode":"if (!BuildTargetDiscovery.GetAllPlatforms().Contains(platformGuid)) throw new InvalidOperationException(\"Unknown platform GUID.\");","typeGuard":"static bool IsValidPlatformGuid(UnityEditor.GUID g) => BuildTargetDiscovery.GetAllPlatforms().Contains(g);","tryCatchPattern":null,"preventionTips":["Resolve platform GUIDs from BuildTargetDiscovery at runtime rather than hardcoding.","Validate GUIDs against GetAllPlatforms() before creation.","Re-resolve persisted GUIDs after Unity upgrades."],"tags":["unity","buildprofile","platform","guid","argumentexception","validation"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}