nodejs/node · error · TypeError
Attempt to merge dict value of unsupported type {v.__class__
Error message
Attempt to merge dict value of unsupported type {v.__class__.__name__} for key {k} What it means
The final else in MergeDicts: a dict value 'v' is not one of the supported types (str, int, dict, or list). For example None, float, tuple, set, or a custom object as a dict value raises TypeError naming the type and key.
Source
Thrown at tools/gyp/pylib/gyp/input.py:2378
+ to[list_base].__class__.__name__
+ " for key "
+ list_base
+ "("
+ k
+ ")"
)
else:
to[list_base] = []
# Call MergeLists, which will make copies of objects that require it.
# MergeLists can recurse back into MergeDicts, although this will be
# to make copies of dicts (with paths fixed), there will be no
# subsequent dict "merging" once entering a list because lists are
# always replaced, appended to, or prepended to.
is_paths = IsPathSection(list_base)
MergeLists(to[list_base], v, to_file, fro_file, is_paths, append)
else:
raise TypeError(
"Attempt to merge dict value of unsupported type "
+ v.__class__.__name__
+ " for key "
+ k
)
def MergeConfigWithInheritance(
new_configuration_dict, build_file, target_dict, configuration, visited
):
# Skip if previously visited.
if configuration in visited:
return
# Look at this configuration.
configuration_dict = target_dict["configurations"][configuration]
# Merge in parents.View on GitHub (pinned to 1b2de5e052)
Solutions
- Make every dict value a str, int, dict, or list.
- Replace None expansions with concrete strings or remove the key.
- Cast floats/bools to str or int as appropriate.
- Inspect generator-emitted dicts for non-standard value types.
Example fix
// before: { 'defines': None }
// after: { 'defines': [] } Defensive patterns
Strategy: type-guard
Validate before calling
def clean_dict(d):
for k, v in d.items():
if type(v) not in (str, int) and not isinstance(v, (dict, list)):
raise TypeError('unsupported dict value type for %s: %r' % (k, type(v)))
Type guard
def is_mergeable_value(v): return type(v) in (str,int) or isinstance(v, (dict,list)) and type(v) is not bool
Try / catch
try:
MergeDicts(to, fro, to_file, fro_file)
except TypeError as e:
if 'unsupported type' in str(e): print('Reduce dict values to str/int/dict/list'); raise Prevention
- Restrict dict values to str/int/dict/list; reject None/bool/float/tuple/set.
- Avoid variable expansions that yield None.
- Validate generator output types.
When it happens
Trigger: During a dict merge, a value associated with some key k is a type MergeDicts cannot handle — str/int/dict/list are the only accepted value types.
Common situations: A variable expanding to None used as a dict value; floats in settings; tuples/sets accidentally introduced by generators; boolean values (type bool) which are NOT matched by `type(v) in (str,int)` and thus fall through.
Related errors
- Attempt to merge list item of unsupported type {item.__class
- Attempt to merge dict value of type {v.__class__.__name__} i
- Incompatible list policies {k} and {list_incompatible}
- Attempt to merge dict value of type {v.__class__.__name__} i
- Found wildcard in {dependency_key} of {target} referring to
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/839da5f00199db9d.
Report an issue: GitHub.