{"record":{"id":"a0405ec6d45a61ed","repo":"nodejs/node","slug":"not-enough-arguments","errorCode":null,"errorMessage":"Not enough arguments","messagePattern":"Not enough arguments","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"tools/gyp/pylib/gyp/flock_tool.py","lineNumber":27,"sourceCode":"import fcntl\nimport os\nimport struct\nimport subprocess\nimport sys\n\n\ndef main(args):\n    executor = FlockTool()\n    executor.Dispatch(args)\n\n\nclass FlockTool:\n    \"\"\"This class emulates the 'flock' command.\"\"\"\n\n    def Dispatch(self, args):\n        \"\"\"Dispatches a string command to a method.\"\"\"\n        if len(args) < 1:\n            raise Exception(\"Not enough arguments\")\n\n        method = \"Exec%s\" % self._CommandifyName(args[0])\n        getattr(self, method)(*args[1:])\n\n    def _CommandifyName(self, name_string):\n        \"\"\"Transforms a tool name like copy-info-plist to CopyInfoPlist\"\"\"\n        return name_string.title().replace(\"-\", \"\")\n\n    def ExecFlock(self, lockfile, *cmd_list):\n        \"\"\"Emulates the most basic behavior of Linux's flock(1).\"\"\"\n        # Rely on exception handling to report errors.\n        # Note that the stock python on SunOS has a bug\n        # where fcntl.flock(fd, LOCK_EX) always fails\n        # with EBADF, that's why we use this F_SETLK\n        # hack instead.\n        fd = os.open(lockfile, os.O_WRONLY | os.O_NOCTTY | os.O_CREAT, 0o666)\n        if sys.platform.startswith(\"aix\") or sys.platform == \"os400\":\n            # Python on AIX is compiled with LARGEFILE support, which changes the","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/gyp/pylib/gyp/flock_tool.py#L9-L45","documentation":"FlockTool.Dispatch raises Exception('Not enough arguments') when invoked with an empty args list. FlockTool emulates Linux's flock(1) for gyp on platforms lacking it; Dispatch expects args[0] to be a command name (e.g. 'flock') that it maps to an Exec<Name> method. With zero args there is no command to dispatch, so it bails immediately.","triggerScenarios":"gyp invoking its flock_tool.py wrapper with no arguments (misconfigured generator or a bad $(flock) substitution); a shell/cmake rule that expands to an empty command string; manually running `python flock_tool.py` with nothing after it.","commonSituations":"Porting a gyp-based build to a new platform whose action template leaves the lockfile command empty; quoting bug that drops the lockfile path and command.","solutions":["Ensure the flock action receives at least a command name, e.g. `python flock_tool.py flock <lockfile> <cmd...>`.","Inspect the gyp generator's action template that emits the flock invocation and fix empty substitutions.","On Linux you can avoid the wrapper by using the native flock(1) if the generator supports it."],"exampleFix":"# before\npython tools/gyp/pylib/gyp/flock_tool.py\n\n# after\npython tools/gyp/pylib/gyp/flock_tool.py flock /tmp/build.lock ninja -C out","handlingStrategy":"validation","validationCode":"def run_flock(args):\n    if not args:\n        raise SystemExit('flock_tool requires at least a command name, e.g. flock <lock> <cmd>')\n    FlockTool().Dispatch(args)","typeGuard":"def has_command_arg(args) -> bool:\n    return len(args) >= 1","tryCatchPattern":"from gyp.flock_tool import main\ntry:\n    main(args)\nexcept Exception as e:\n    if 'Not enough arguments' in str(e):\n        raise SystemExit('Usage: flock_tool.py flock <lockfile> <cmd...>')","preventionTips":["Validate the flock action template produces a non-empty command before invoking flock_tool.","On Linux, prefer native flock(1) to avoid the Python wrapper.","Quote shell expansions so the lockfile path and command aren't dropped."],"tags":["gyp","flock","cli","arguments","build"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}