{"record":{"id":"457f4bcd907ac7ce","repo":"Unity-Technologies/UnityCsReference","slug":"0-the-raw-string-was-1","errorCode":null,"errorMessage":"{0}, the raw string was {1}","messagePattern":"(.+?), the raw string was (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Editor/Mono/PlayerSettingsWSA.cs","lineNumber":91,"sourceCode":"\n            public static void SetVisualAssetsImage(string image, WSAImageType type, WSAImageScale scale)\n            {\n                ValidateWSAImageType(type);\n                ValidateWSAImageScale(scale);\n                SetWSAImage(image, type, scale);\n            }\n\n            public static System.Version packageVersion\n            {\n                get\n                {\n                    try\n                    {\n                        return new System.Version(ValidatePackageVersion(packageVersionRaw));\n                    }\n                    catch (Exception ex)\n                    {\n                        throw new Exception(string.Format(\"{0}, the raw string was {1}\", ex.Message, packageVersionRaw));\n                    }\n                }\n                set { packageVersionRaw = value.ToString(); }\n            }\n\n\n            public static System.DateTime? certificateNotAfter\n            {\n                get\n                {\n                    long value = certificateNotAfterRaw;\n                    if (value != 0)\n                        return System.DateTime.FromFileTime(value);\n                    else\n                        return null;\n                }\n            }\n","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/PlayerSettingsWSA.cs#L73-L109","documentation":"The packageVersion getter wraps any exception from constructing System.Version(ValidatePackageVersion(packageVersionRaw)) and rethrows it as a new System.Exception formatted \"{inner message}, the raw string was <packageVersionRaw>\". In normal operation ValidatePackageVersion normalizes the value to either the regex-matched d.d.d.d form or the fallback \"1.0.0.0\", both valid for System.Version, so this throw is effectively unreachable through the public getter unless packageVersionRaw is corrupted at the native/storage layer or a future change breaks the contract. It exists to surface the offending raw string when version parsing fails.","triggerScenarios":"The native backing field packageVersionRaw holding a value that defeats ValidatePackageVersion's normalization (corrupted PlayerSettings serialization, direct native mutation, or a non-string object). Effectively cannot fire from managed-only code paths because both ValidatePackageVersion outputs parse cleanly.","commonSituations":"Corrupted Library/ProjectSettings serialization after a crash, hand-edited or merge-conflicted ProjectSettings asset affecting the WSA package version field, or a bug in a native editor extension writing an invalid value. Exceedingly rare in normal use.","solutions":["Wrap reads of packageVersion in try/catch (Exception) and report the raw value from your own log, since the engine already attaches it.","Reset the WSA package version in Player Settings UI to a clean major.minor.build.revision value.","If persistently reproducible, inspect packageVersionRaw source / ProjectSettings asset for corruption and re-save it.","Report a Unity bug if a valid 4-part numeric version still triggers the throw (would indicate an engine regression)."],"exampleFix":"// before\nSystem.Version v = PlayerSettings.WSA.packageVersion;\n\n// after — defensive read with explicit fallback policy\nSystem.Version v;\ntry\n{\n    v = PlayerSettings.WSA.packageVersion;\n}\ncatch (Exception ex)\n{\n    UnityEngine.Debug.LogError(\"Failed to read WSA packageVersion: \" + ex.Message);\n    v = new System.Version(1, 0, 0, 0);\n}","handlingStrategy":"try-catch","validationCode":"// packageVersion normalizes internally, so pre-validation is limited to the raw field shape.\nstatic bool LooksLikeValidPackageVersion(string raw)\n    => !string.IsNullOrEmpty(raw) &&\n       System.Text.RegularExpressions.Regex.IsMatch(raw, @\"^\\d+\\.\\d+\\.\\d+\\.\\d+$\");","typeGuard":null,"tryCatchPattern":"System.Version v;\ntry\n{\n    v = PlayerSettings.WSA.packageVersion;\n}\ncatch (System.Exception ex)\n{\n    // The engine already appends \", the raw string was <value>\" to the message.\n    UnityEngine.Debug.LogError(\"WSA packageVersion read failed: \" + ex.Message);\n    v = new System.Version(1, 0, 0, 0);\n}","preventionTips":["Always read packageVersion inside try/catch; the getter can rethrow a wrapped exception.","Set the WSA package version through the Player Settings UI or a clean 4-part numeric string.","Treat Library/ProjectSettings corruption as a trigger; re-save the asset if the throw recurs.","File a Unity bug if a valid major.minor.build.revision value still causes the throw."],"tags":["unity","wsa","uwp","versioning","exception-wrapping","playersettings","editor-only","defensive"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}