nodejs/node · error · ValueError
Invalid MSVS guid: "%s". Must match regex: "%s".
Error message
Invalid MSVS guid: "%s". Must match regex: "%s".
What it means
Raised as a ValueError when a target specifies an 'msvs_guid' that does not match the VALID_MSVS_GUID_CHARS regex. The guid is read from the default configuration's msvs_guid and validated before being wrapped in braces. An invalid guid would produce a corrupt .vcproj/.sln that Visual Studio cannot open.
Source
Thrown at tools/gyp/pylib/gyp/generator/msvs.py:978
def _GetGuidOfProject(proj_path, spec):
"""Get the guid for the project.
Arguments:
proj_path: Path of the vcproj or vcxproj file to generate.
spec: The target dictionary containing the properties of the target.
Returns:
the guid.
Raises:
ValueError: if the specified GUID is invalid.
"""
# Pluck out the default configuration.
default_config = _GetDefaultConfiguration(spec)
# Decide the guid of the project.
guid = default_config.get("msvs_guid")
if guid:
if VALID_MSVS_GUID_CHARS.match(guid) is None:
raise ValueError(
'Invalid MSVS guid: "%s". Must match regex: "%s".'
% (guid, VALID_MSVS_GUID_CHARS.pattern)
)
guid = "{%s}" % guid
guid = guid or MSVSNew.MakeGuid(proj_path)
return guid
def _GetMsbuildToolsetOfProject(proj_path, spec, version):
"""Get the platform toolset for the project.
Arguments:
proj_path: Path of the vcproj or vcxproj file to generate.
spec: The target dictionary containing the properties of the target.
version: The MSVSVersion object.
Returns:
the platform toolset string or None.
"""View on GitHub (pinned to 1b2de5e052)
Solutions
- Provide the guid as a bare hex string matching the expected pattern (no surrounding braces, valid hex characters).
- Remove the msvs_guid override entirely to let gyp auto-generate a stable guid via MSVSNew.MakeGuid.
- Verify the guid against VALID_MSVS_GUID_CHARS.pattern and correct any invalid characters.
Example fix
// before
'targets': [{
'target_name': 'foo',
'configurations': { 'Debug': { 'msvs_guid': '{ABC-123}' } }
}]
// after — bare hex, valid char set, correct length
'targets': [{
'target_name': 'foo',
'configurations': { 'Debug': { 'msvs_guid': 'AA1BB2CC3DD4EE5FF6A7B8C9D0E1F2A3' } }
}] Defensive patterns
Strategy: validation
Validate before calling
import re
VALID = re.compile(r'^[A-Fa-f0-9]{32}$')
guid = 'AA1BB2CC3DD4EE5FF6A7B8C9D0E1F2A3'
if not VALID.match(guid):
raise ValueError('invalid msvs_guid format') Type guard
import re
_VALID = re.compile(r'^[A-Fa-f0-9]{32}$')
def is_valid_msvs_guid(g) -> bool:
return isinstance(g, str) and bool(_VALID.match(g)) Prevention
- Let gyp auto-generate guids unless you have a specific stability requirement.
- Provide the guid as a bare hex string without braces.
When it happens
Trigger: Setting 'msvs_guid' in a target's configuration to a string containing characters outside the allowed set (typically hex digits without braces/with invalid formatting). VALID_MSVS_GUID_CHARS.match returns None at msvs.py:980.
Common situations: Hardcoding a guid with braces already included (the code adds braces itself); using lowercase/uppercase rules mismatch; a typo or non-hex character in a hand-authored guid; copy-pasting a guid format from a different tool.
Related errors
- Target type %s is not a valid target type for target %s in %
- AddFileConfig: file "%s" not in project.
- expected string; got %r
- expected string list; got %r
- expected bool; got %r
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/81c3ec36ddd7d25c.
Report an issue: GitHub.