{"record":{"id":"9a1cc2a5f465575c","repo":"apache/beam","slug":"no-proto-files-found-in-s-not-in-apache-git-tree-unable-to","errorCode":null,"errorMessage":"No proto files found in %s. / Not in apache git tree, unable to find proto definitions.","messagePattern":"No proto files found in (.+?)\\. / Not in apache git tree, unable to find proto definitions\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"sdks/python/gen_protos.py","lineNumber":445,"sourceCode":"      proto_file for d in proto_dirs for proto_file in find_by_ext(d, '.proto')\n  ]\n\n  out_files = list(find_by_ext(PYTHON_OUTPUT_PATH, '_pb2.py'))\n\n  if out_files and not proto_files and not force:\n    # We have out_files but no protos; assume they're up-to-date.\n    # This is actually the common case (e.g. installation from an sdist).\n    LOG.info('No proto files; using existing generated files.')\n    return\n\n  elif not out_files and not proto_files:\n    model = os.path.join(PROJECT_ROOT, 'model')\n    if os.path.exists(model):\n      error_msg = 'No proto files found in %s.' % proto_dirs\n    else:\n      error_msg = 'Not in apache git tree, unable to find proto definitions.'\n\n    raise RuntimeError(error_msg)\n\n  if force:\n    regenerate_reason = 'forced'\n  elif not out_files:\n    regenerate_reason = 'no output files'\n  elif len(out_files) < len(proto_files):\n    regenerate_reason = 'not enough output files'\n  elif (min(os.path.getmtime(path) for path in out_files) <= max(\n      os.path.getmtime(path)\n      for path in proto_files + [os.path.realpath(__file__)])):\n    regenerate_reason = 'output files are out-of-date'\n  elif len(out_files) > len(proto_files):\n    regenerate_reason = 'output files without corresponding .proto files'\n    # too many output files: probably due to switching between git branches.\n    # remove them so they don't trigger constant regeneration.\n    for out_file in out_files:\n      os.remove(out_file)\n  else:","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/gen_protos.py#L427-L463","documentation":"generate_proto_files discovers Beam's .proto files relative to the git tree (PROJECT_ROOT/model etc.). If none are found, it raises RuntimeError with a message distinguishing 'No proto files found' (in the tree, protos deleted/moved) from 'Not in apache git tree' (e.g. running from a pip-installed package or tarball without sources).","triggerScenarios":"Running gen_protos.py outside a full Apache Beam git checkout (e.g. from an installed wheel or extracted sdist), or inside the tree but with the model/ proto directories missing or moved.","commonSituations":"Attempting regeneration from a released Beam package; working in a shallow/partial clone or after removing submodule/model directories.","solutions":["Clone the full apache/beam git repository and run the script from its sdks/python directory.","Verify model/ and sdks/python/proto paths exist relative to PROJECT_ROOT.","Skip regeneration if you only need pre-generated protos (they ship with the package)."],"exampleFix":"// before\npip install apache-beam && python -c 'import gen_protos'\n// after\ngit clone https://github.com/apache/beam.git && cd beam/sdks/python && python gen_protos.py","handlingStrategy":"validation","validationCode":"import os\nmodel = os.path.join(os.getcwd(), '..', '..', 'model')\nassert os.path.isdir(model) and any(f.endswith('.proto') for _, _, fs in os.walk(model) for f in fs), \\\n    'run gen_protos.py from a full apache/beam git checkout'","typeGuard":"def in_beam_git_tree():\n    import os\n    return os.path.isdir(os.path.join(os.getcwd(), '..', '..', 'model'))","tryCatchPattern":"try:\n    generate_proto_files()\nexcept RuntimeError as e:\n    if 'Not in apache git tree' in str(e):\n        print('Clone apache/beam sources before regenerating protos')","preventionTips":["Only run gen_protos.py inside a full git clone of apache/beam.","Never attempt regeneration from pip-installed packages or sdists.","Keep model/ directories intact in shallow CI checkouts."],"tags":["protobuf","build","source-tree","code-generation"],"backgroundTag":"file-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}