Unity-Technologies/UnityCsReference · error · ArgumentException

Invalid version string in {filterName} for {fieldName}="{val

Error message

Invalid version string in {filterName} for {fieldName}="{value}": {versionErrorMessage}

What it means

Thrown by the obsolete VulkanDeviceFilter.CheckVersion method when a version string does not match the expected format: either 'Major.Minor.Patch' (where Minor and Patch are optional, numbers only) or a hex number starting with '0x' (max 4 bytes / 8 hex digits). This validates GPU device filter version constraints used in the Android Vulkan device filter list. The method is obsolete — use VulkanDeviceFilterLists API instead.

Source

Thrown at Editor/Mono/PlayerSettingsAndroid.bindings.cs:995

            [Obsolete("driverVersionStringValue is obsolete. Use VulkanDeviceFilterLists api instead.")]
            private static readonly string driverVersionStringValue = "driverVersionString";

            // Keep in sync with same error message in VulkanDeviceFilterLists.Bindings.cs
            [Obsolete("versionErrorMessage is obsolete. Use VulkanDeviceFilterLists api instead.")]
            private static readonly string versionErrorMessage = "Version information should be formatted as:" +
                "\n1. 'MajorVersion.MinorVersion.PatchVersion' where MinorVersion and PatchVersion are optional and must only " +
                "contain numbers, or \n2. Hex number beginning with '0x' (max 4-bytes)";

            // Keep in sync with validVersionString in VulkanDeviceFilterLists.Bindings.cs
            [Obsolete("validVersionString is obsolete. Use VulkanDeviceFilterLists api instead.")]
            private static readonly Regex validVersionString = new Regex(@"(^[0-9]+(\.[0-9]+){0,2}$)|(^0(x|X)([A-Fa-f0-9]{1,8})$)", RegexOptions.Compiled);

            [Obsolete("CheckVersion is obsolete. Use VulkanDeviceFilterLists api instead.")]
            internal static void CheckVersion(string value, string filterName, string fieldName)
            {
                if (!validVersionString.IsMatch(value))
                    throw new ArgumentException($"Invalid version string in {filterName} for {fieldName}=\"{value}\": {versionErrorMessage}");
            }

            [Obsolete("CheckRegex is obsolete. Use VulkanDeviceFilterLists api instead.")]
            internal static void CheckRegex(string value, string filterName, string fieldName)
            {
                try
                {
                    // Try to create a regex from the input string to determine if it is a valid regex
                    Regex regex = new Regex(value);
                }
                catch (ArgumentException e)
                {
                    throw new ArgumentException($"Invalid Regular Expression in {filterName} for {fieldName}=\"{value}\": {e.Message}");
                }
            }

            [Obsolete("CheckAllFilterData is obsolete. Use VulkanDeviceFilterLists api instead.")]
            internal static void CheckAllFilterData(AndroidDeviceFilterData[] filterDataList, string filterName)

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Format version strings as 'Major.Minor.Patch' (e.g. '1.1.0') or hex (e.g. '0x110000') matching the regex.
  2. Migrate to the VulkanDeviceFilterLists API which replaces the obsolete CheckVersion method.
  3. Validate version strings against the regex before assigning: Regex.IsMatch(value, pattern).

Example fix

// before
CheckVersion("v1.2", filterName, fieldName); // invalid prefix

// after
CheckVersion("1.2", filterName, fieldName);
Defensive patterns

Strategy: validation

Validate before calling

var pattern = @"(^[0-9]+(\.[0-9]+){0,2}$)|(^0(x|X)([A-Fa-f0-9]{1,8})$)";
if (Regex.IsMatch(value, pattern))
    CheckVersion(value, filterName, fieldName);

Prevention

When it happens

Trigger: Calling CheckVersion with a version string that doesn't match the regex (^[0-9]+(\.[0-9]+){0,2}$)|(^0(x|X)([A-Fa-f0-9]{1,8})$). Examples: '1.2.3.4' (too many segments), 'v1.0' (invalid prefix), '0x123456789' (too many hex digits), '1.x' (non-numeric).

Common situations: Editing Vulkan device filter lists in Android player settings; copying version strings from device specifications that use different formats; upgrading from a Unity version with looser validation; using the obsolete API after migration guidance was issued.

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/8b5d7c65e6690eae. Report an issue: GitHub.