{"record":{"id":"20ec2515745438af","repo":"nodejs/node","slug":"depfile-requires-stamp-and-vice-versa","errorCode":null,"errorMessage":"--depfile requires --stamp and vice versa","messagePattern":"--depfile requires --stamp and vice versa","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"deps/inspector_protocol/code_generator.py","lineNumber":87,"sourceCode":"    cmdline_parser = argparse.ArgumentParser()\n    cmdline_parser.add_argument(\"--output_base\", type=unicode, required=True)\n    cmdline_parser.add_argument(\"--jinja_dir\", type=unicode, required=True)\n    cmdline_parser.add_argument(\"--config\", type=unicode, required=True)\n    cmdline_parser.add_argument(\"--config_value\", default=[], action=\"append\")\n    cmdline_parser.add_argument(\n      \"--inspector_protocol_dir\", type=unicode, required=True,\n      help=(\"directory with code_generator.py and C++ encoding / binding \"\n          \"libraries, relative to the root of the source tree.\"))\n    cmdline_parser.add_argument(\"--depfile\", type=unicode, required=False)\n    cmdline_parser.add_argument(\"--stamp\", type=unicode, required=False)\n    arg_options = cmdline_parser.parse_args()\n    jinja_dir = arg_options.jinja_dir\n    output_base = arg_options.output_base\n    config_file = arg_options.config\n    config_base = os.path.dirname(config_file)\n    config_values = arg_options.config_value\n    if bool(arg_options.depfile) != bool(arg_options.stamp):\n      raise Exception(\"--depfile requires --stamp and vice versa\")\n    depfile = arg_options.depfile\n    stamp = arg_options.stamp\n    inspector_protocol_dir = arg_options.inspector_protocol_dir.lstrip('/')\n  except Exception:\n    # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html\n    exc = sys.exc_info()[1]\n    sys.stderr.write(\"Failed to parse command-line arguments: %s\\n\\n\" % exc)\n    exit(1)\n\n  try:\n    config_json_file = open(config_file, \"r\")\n    config_json_string = config_json_file.read()\n    config_partial = json_to_object(config_json_string, output_base,\n                                    config_base)\n    config_json_file.close()\n    defaults = {\n      \".use_snake_file_names\": False,\n      \".use_title_case_methods\": False,","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/inspector_protocol/code_generator.py#L69-L105","documentation":"The inspector-protocol code_generator.py emits a depfile (a make/ninja dependency list) only when it also has a stamp file to write, and vice versa. It enforces this with `bool(arg_options.depfile) != bool(arg_options.stamp)`, so exactly one of the two being set is an error; both empty or both set is fine.","triggerScenarios":"Raised in main() when exactly one of --depfile / --stamp is passed via the command line. Both are argparse optional strings, so the XOR check is the only guard.","commonSituations":"GYP/gn rule edits that wired up depfile generation but forgot the stamp target (or the reverse); partial ports of the inspector-protocol build rule to a new generator; manual invocation while debugging the protocol bindings.","solutions":["Supply both --depfile <path> and --stamp <path>, or omit both.","If you added --depfile to capture dependencies, add the matching --stamp so the build knows when to regenerate.","Check the calling gyp/gn action and align the two argument lists."],"exampleFix":"# before\npython code_generator.py --depfile out/dep.d ...\n# after\npython code_generator.py --depfile out/dep.d --stamp out/stamp ...","handlingStrategy":"validation","validationCode":"if bool(args.depfile) != bool(args.stamp):\n    raise SystemExit('--depfile and --stamp must be supplied together or both omitted')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always template --depfile and --stamp as a pair in gn/gyp action rules.","Add a unit test on the build rule that both flags move together."],"tags":["inspector-protocol","build","gn","gyp","flag-conflict"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}