{"record":{"id":"d0ddf9bb5cd21116","repo":"Unity-Technologies/UnityCsReference","slug":"unknown-wsa-image-type-type","errorCode":null,"errorMessage":"Unknown WSA image type: {type}","messagePattern":"Unknown WSA image type: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Editor/Mono/PlayerSettingsWSA.cs","lineNumber":43,"sourceCode":"                {\n                    return \"1.0.0.0\";\n                }\n            }\n\n            internal static void ValidateWSAImageType(WSAImageType type)\n            {\n                switch (type)\n                {\n                    case WSAImageType.PackageLogo:\n                    case WSAImageType.SplashScreenImage:\n                    case WSAImageType.UWPSquare44x44Logo:\n                    case WSAImageType.UWPSquare71x71Logo:\n                    case WSAImageType.UWPSquare150x150Logo:\n                    case WSAImageType.UWPSquare310x310Logo:\n                    case WSAImageType.UWPWide310x150Logo:\n                        return;\n                    default:\n                        throw new Exception(\"Unknown WSA image type: \" + type);\n                }\n            }\n\n            internal static void ValidateWSAImageScale(WSAImageScale scale)\n            {\n                switch (scale)\n                {\n                    case WSAImageScale._100:\n                    case WSAImageScale._125:\n                    case WSAImageScale._150:\n                    case WSAImageScale._200:\n                    case WSAImageScale._400:\n                    case WSAImageScale.Target16:\n                    case WSAImageScale.Target24:\n                    case WSAImageScale.Target32:\n                    case WSAImageScale.Target48:\n                    case WSAImageScale.Target256:\n                        return;","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/PlayerSettingsWSA.cs#L25-L61","documentation":"ValidateWSAImageType throws a plain System.Exception with \"Unknown WSA image type: <type>\" when a WSAImageType enum value is not one of the seven handled cases (PackageLogo, SplashScreenImage, UWPSquare44x44Logo, UWPSquare71x71Logo, UWPSquare150x150Logo, UWPSquare310x310Logo, UWPWide310x150Logo). The method is called by GetVisualAssetsImage/SetVisualAssetsImage and is a defensive default branch — it fires when a caller casts an arbitrary integer to the enum (e.g. (WSAImageType)999) or passes a value added to the enum in a newer engine version that this validation predates.","triggerScenarios":"Passing a cast integer like (WSAImageType)42 to GetVisualAssetsImage or SetVisualAssetsImage; reading an unvalidated WSAImageType from a serialized config/JSON and forwarding it; calling these APIs on an engine build whose WSAImageType enum has new members not present in the switch.","commonSituations":"Build scripts that deserialize PlayerSettings overrides from YAML/JSON and cast loosely. Automated tooling enumerating enum values by integer. Version skew between the editor compiling the script and the editor running it.","solutions":["Validate the WSAImageType with Enum.IsDefined before calling Get/SetVisualAssetsImage.","Stop casting raw integers to the enum; only use named WSAImageType members.","If the value comes from serialized data, sanitize/whitelist it against the known set before forwarding.","Upgrade the calling code to the same Unity version as the running editor so any new enum members are visible at compile time."],"exampleFix":"// before — unsafe cast can fall through the switch\nvar img = PlayerSettings.WSA.GetVisualAssetsImage((WSAImageType)rawInt, WSAImageScale._100);\n\n// after — whitelist before calling\nWSAImageType type = (WSAImageType)rawInt;\nif (!Enum.IsDefined(typeof(WSAImageType), type) ||\n    (type != WSAImageType.PackageLogo &&\n     type != WSAImageType.SplashScreenImage &&\n     type != WSAImageType.UWPSquare44x44Logo &&\n     type != WSAImageType.UWPSquare71x71Logo &&\n     type != WSAImageType.UWPSquare150x150Logo &&\n     type != WSAImageType.UWPSquare310x310Logo &&\n     type != WSAImageType.UWPWide310x150Logo))\n{\n    throw new ArgumentOutOfRangeException(nameof(type), type, \"Unsupported WSAImageType\");\n}\nvar img = PlayerSettings.WSA.GetVisualAssetsImage(type, WSAImageScale._100);","handlingStrategy":"validation","validationCode":"static readonly HashSet<WSAImageType> AllowedTypes = new HashSet<WSAImageType>\n{\n    WSAImageType.PackageLogo, WSAImageType.SplashScreenImage,\n    WSAImageType.UWPSquare44x44Logo, WSAImageType.UWPSquare71x71Logo,\n    WSAImageType.UWPSquare150x150Logo, WSAImageType.UWPSquare310x310Logo,\n    WSAImageType.UWPWide310x150Logo,\n};\n\nstatic bool IsValid(WSAImageType t) => Enum.IsDefined(typeof(WSAImageType), t) && AllowedTypes.Contains(t);\n\nif (!IsValid(type)) throw new ArgumentOutOfRangeException(nameof(type), type, \"Unsupported WSAImageType\");\nvar img = PlayerSettings.WSA.GetVisualAssetsImage(type, WSAImageScale._100);","typeGuard":"static bool IsSupportedWSAImageType(WSAImageType t)\n{\n    switch (t)\n    {\n        case WSAImageType.PackageLogo:\n        case WSAImageType.SplashScreenImage:\n        case WSAImageType.UWPSquare44x44Logo:\n        case WSAImageType.UWPSquare71x71Logo:\n        case WSAImageType.UWPSquare150x150Logo:\n        case WSAImageType.UWPSquare310x310Logo:\n        case WSAImageType.UWPWide310x150Logo:\n            return true;\n        default:\n            return false;\n    }\n}","tryCatchPattern":"// ValidateWSAImageType throws a bare System.Exception; validate instead of catching.\nif (!IsSupportedWSAImageType(type))\n    throw new ArgumentOutOfRangeException(nameof(type), type, \"Unsupported WSAImageType\");\n\ntry { var img = PlayerSettings.WSA.GetVisualAssetsImage(type, scale); }\ncatch (System.Exception ex) when (ex.Message.StartsWith(\"Unknown WSA image type\"))\n{\n    // last-resort guard for version-skew additions to the enum\n    UnityEngine.Debug.LogError(ex.Message);\n}","preventionTips":["Never cast arbitrary integers to WSAImageType; use named members.","Validate enums with Enum.IsDefined plus an explicit allow-list before calling Get/SetVisualAssetsImage.","Keep editor scripts on the same Unity version as the running editor so enum shapes match.","Sanitize deserialized WSAImageType values from JSON/YAML against the known set."],"tags":["unity","wsa","uwp","enum","validation","playersettings","editor-only","switch-default"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}