{"record":{"id":"34b0adf2a9c34f32","repo":"nodejs/node","slug":"the-action-for-run-as-in-target-s-from-file","errorCode":null,"errorMessage":"The 'action' for 'run_as' in target %s from file %s must be a list.","messagePattern":"The 'action' for 'run_as' in target (.+?) from file (.+?) must be a list\\.","errorType":"exception","errorClass":"GypError","httpStatus":null,"severity":"error","filePath":"tools/gyp/pylib/gyp/input.py","lineNumber":2787,"sourceCode":"\ndef ValidateRunAsInTarget(target, target_dict, build_file):\n    target_name = target_dict.get(\"target_name\")\n    run_as = target_dict.get(\"run_as\")\n    if not run_as:\n        return\n    if not isinstance(run_as, dict):\n        raise GypError(\n            \"The 'run_as' in target %s from file %s should be a \"\n            \"dictionary.\" % (target_name, build_file)\n        )\n    action = run_as.get(\"action\")\n    if not action:\n        raise GypError(\n            \"The 'run_as' in target %s from file %s must have an \"\n            \"'action' section.\" % (target_name, build_file)\n        )\n    if not isinstance(action, list):\n        raise GypError(\n            \"The 'action' for 'run_as' in target %s from file %s \"\n            \"must be a list.\" % (target_name, build_file)\n        )\n    working_directory = run_as.get(\"working_directory\")\n    if working_directory and not isinstance(working_directory, str):\n        raise GypError(\n            \"The 'working_directory' for 'run_as' in target %s \"\n            \"in file %s should be a string.\" % (target_name, build_file)\n        )\n    environment = run_as.get(\"environment\")\n    if environment and not isinstance(environment, dict):\n        raise GypError(\n            \"The 'environment' for 'run_as' in target %s \"\n            \"in file %s should be a dictionary.\" % (target_name, build_file)\n        )\n\n\ndef ValidateActionsInTarget(target, target_dict, build_file):","sourceCodeStart":2769,"sourceCodeEnd":2805,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/gyp/pylib/gyp/input.py#L2769-L2805","documentation":"run_as.action must be a list of command arguments (argv form). A scalar string or dict is rejected so that gyp can pass the list straight through to the spawned process without splitting logic.","triggerScenarios":"run_as['action'] is present and truthy but isinstance(action, list) is False (e.g. a single string).","commonSituations":"Writing 'action': 'my_app --flag' as a shell-style string instead of an argv list; migrating from a format that used strings.","solutions":["Convert the action value into a list where each element is one argument.","Ensure the program path and each flag are separate list entries.","Re-run gyp."],"exampleFix":"// before\n'run_as': { 'action': 'my_app --flag' },\n// after\n'run_as': { 'action': ['my_app', '--flag'] },","handlingStrategy":"type-guard","validationCode":"ra = target_dict.get('run_as')\nif isinstance(ra, dict):\n    a = ra.get('action')\n    if a is not None and not isinstance(a, list):\n        raise TypeError('run_as.action must be a list')","typeGuard":"def run_as_action_is_list(target_dict: dict) -> bool:\n    ra = target_dict.get('run_as')\n    if not isinstance(ra, dict):\n        return True\n    a = ra.get('action')\n    return a is None or isinstance(a, list)","tryCatchPattern":null,"preventionTips":["Use argv list form ['prog', '--flag'] for action, never a shell string.","Keep a shared lint helper that asserts run_as.action is a list."],"tags":["gyp","run-as","type","action","validation"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}