nodejs/node · error · TypeError
Unknown type {value.__class__.__name__} for {key}
Error message
Unknown type {value.__class__.__name__} for {key} What it means
When ProcessVariablesAndConditionsInDict recurses over the_dict's keys, it handles dict, list, str, and int values; anything else (e.g. a bool, float, None, tuple) reaches the final elif and raises this TypeError naming the class and the key. GYP build dicts are JSON-like and only support those four value types.
Source
Thrown at tools/gyp/pylib/gyp/input.py:1398
for key, value in the_dict.items():
# Skip "variables" and string values, which were already processed if
# present.
if key == "variables" or isinstance(value, str):
continue
if isinstance(value, dict):
# Pass a copy of the variables dict so that subdicts can't influence
# parents.
ProcessVariablesAndConditionsInDict(
value, phase, variables, build_file, key
)
elif isinstance(value, list):
# The list itself can't influence the variables dict, and
# ProcessVariablesAndConditionsInList will make copies of the variables
# dict if it needs to pass it to something that can influence it. No
# copy is necessary here.
ProcessVariablesAndConditionsInList(value, phase, variables, build_file)
elif not isinstance(value, int):
raise TypeError("Unknown type " + value.__class__.__name__ + " for " + key)
def ProcessVariablesAndConditionsInList(the_list, phase, variables, build_file):
# Iterate using an index so that new values can be assigned into the_list.
index = 0
while index < len(the_list):
item = the_list[index]
if isinstance(item, dict):
# Make a copy of the variables dict so that it won't influence anything
# outside of its own scope.
ProcessVariablesAndConditionsInDict(item, phase, variables, build_file)
elif isinstance(item, list):
ProcessVariablesAndConditionsInList(item, phase, variables, build_file)
elif isinstance(item, str):
expanded = ExpandVariables(item, phase, variables, build_file)
if type(expanded) in (str, int):
the_list[index] = expanded
elif isinstance(expanded, list):View on GitHub (pinned to 1b2de5e052)
Solutions
- Replace the offending value with a string or int — e.g. use '1'/'0' or 1/0 instead of True/False, and a string for floats.
- Remove the key if it is not meaningful to GYP.
- Audit the programmatic caller or .gypi include that produced the value.
Example fix
// before 'enable_feature': True, // after 'enable_feature': 1, // or '1'
Defensive patterns
Strategy: type-guard
Validate before calling
for key, value in the_dict.items():
assert isinstance(value, (dict, list, str, int)), \
f'Value for {key!r} has unsupported type {type(value).__name__}' Type guard
def is_supported_gyp_value(value) -> bool:
return isinstance(value, (dict, list, str, int)) and not isinstance(value, bool) Prevention
- GYP has no native boolean — use '1'/'0' or 1/0.
- Avoid None/null values in .gyp and .gypi files.
- Lint programmatic gyp callers to emit only dict/list/str/int.
When it happens
Trigger: A .gyp file (or a programmatic gyp caller) places a bool, float, None, or tuple as a dict value; JSON config injection that yields null/true/false where GYP expects a string/int; hand-edit introducing a Python-only literal.
Common situations: Writing 'something': None or 'flag': True in a .gyp file (GYP has no native boolean — use '1'/'0'); floating-point versions; a templating layer injecting JSON nulls.
Related errors
- %s must be a list
- %s %s must be followed by a dictionary, not %s
- Unknown type {item.__class__.__name__} at index {index}
- Unknown command string '%s' in '%s'.
- Variable %s must expand to a string or list of strings; list
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/b9a97905a95bfa30.
Report an issue: GitHub.