nodejs/node · error · ValueError

Unrecognized action {action} in {name} key {regex_key}

Error message

Unrecognized action {action} in {name} key {regex_key}

What it means

Regex list filters use [action, pattern] tuples where action must be 'exclude' or 'include'. Any other action string raises ValueError (note: ValueError) naming the bad action, the dict name, and the regex key.

Source

Thrown at tools/gyp/pylib/gyp/input.py:2603

            # The "whatever!" list is no longer needed, dump it.
            del the_dict[exclude_key]

        regex_key = list_key + "/"
        if regex_key in the_dict:
            for regex_item in the_dict[regex_key]:
                [action, pattern] = regex_item
                pattern_re = re.compile(pattern)

                if action == "exclude":
                    # This item matches an exclude regex, set its value to 0 (exclude).
                    action_value = 0
                elif action == "include":
                    # This item matches an include regex, set its value to 1 (include).
                    action_value = 1
                else:
                    # This is an action that doesn't make any sense.
                    raise ValueError(
                        "Unrecognized action "
                        + action
                        + " in "
                        + name
                        + " key "
                        + regex_key
                    )

                for index, list_item in enumerate(the_list):
                    if list_actions[index] == action_value:
                        # Even if the regex matches, nothing will change so continue
                        # (regex searches are expensive).
                        continue
                    if pattern_re.search(list_item):
                        # Regular expression match.
                        list_actions[index] = action_value

            # The "whatever/" list is no longer needed, dump it.

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Use only 'exclude' or 'include' as the action in each regex tuple.
  2. Spell-check the action verb.
  3. Update generators to emit only the two supported actions.

Example fix

// before: 'sources/': [['exlude', '.*\\.test\\.cc$']]
// after: 'sources/': [['exclude', '.*\\.test\\.cc$']]
Defensive patterns

Strategy: validation

Validate before calling

for k, lst in the_dict.items():
    if k[-1:] == '/':
        for action, pattern in lst:
            assert action in ('exclude', 'include'), 'bad action %r in %s' % (action, k)

Type guard

def valid_regex_actions(lst): return all(a in ('exclude','include') for a, _ in lst)

Try / catch

try:
    gyp.main(args)
except ValueError as e:
    if 'Unrecognized action' in str(e): print('Use only exclude/include'); raise

Prevention

When it happens

Trigger: A regex filter list (key ending in '/') contains a tuple whose first element is neither 'exclude' nor 'include'. Also fires if the tuple is malformed such that action resolves to an unexpected value.

Common situations: Typo like 'exlude' or 'inc'; copy-paste from docs that used a different verb; generator emitting custom action verbs; structural change to the tuple format.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/817a4ef229bf0a75. Report an issue: GitHub.