{"record":{"id":"710ca9052d795e97","repo":"apache/beam","slug":"skipping-proto-generation-as-they-are-already-generated","errorCode":null,"errorMessage":"Skipping proto generation as they are already generated.","messagePattern":"Skipping proto generation as they are already generated\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"sdks/python/setup.py","lineNumber":251,"sourceCode":"  try:\n    # Pyproject toml build happens in isolated environemnts. In those envs,\n    # gen_protos is unable to get imported. so we run a subprocess call.\n    cwd = os.path.abspath(os.path.dirname(__file__))\n    # when pip install <>.tar.gz gets called, if gen_protos.py is not available\n    # in the sdist,then the proto files would have already been generated. So we\n    # skip proto generation in that case.\n    if not os.path.exists(os.path.join(cwd, 'gen_protos.py')):\n      # make sure we already generated protos\n      pb2_files = list(\n          find_by_ext(\n              os.path.join(cwd, 'apache_beam', 'portability', 'api'),\n              '_pb2.py'))\n      if not pb2_files:\n        raise RuntimeError(\n            'protobuf files are not generated. '\n            'Please generate pb2 files')\n\n      warnings.warn('Skipping proto generation as they are already generated.')\n      return\n    out = subprocess.run(\n        [sys.executable, os.path.join(cwd, 'gen_protos.py'), '--no-force'],\n        capture_output=True,\n        check=True)\n    print(out.stdout)\n  except subprocess.CalledProcessError as err:\n    raise RuntimeError('Could not generate protos due to error: %s', err.stderr)\n\n\ndef copy_tests_from_docs():\n  python_root = os.path.abspath(os.path.dirname(__file__))\n  docs_src = os.path.normpath(\n      os.path.join(\n          python_root, '../../website/www/site/content/en/documentation/sdks'))\n  docs_dest = os.path.normpath(\n      os.path.join(python_root, 'apache_beam/yaml/docs'))\n  if os.path.exists(docs_src):","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/setup.py#L233-L269","documentation":"Beam's generate_protos_first target checks whether generated *_pb2.py files already exist; if so it warns that proto regeneration is skipped and returns without invoking gen_protos.py. It ensures stale/absent regeneration is explicit rather than silently re-running codegen.","triggerScenarios":"Running the proto-generation setup target (generate_protos_first) when the sdks/python directory already contains generated _pb2.py files, so the codegen subprocess is bypassed.","commonSituations":"Re-running builds after a partial codegen; developers who edited .proto files but still see old generated code because pb2 files exist and generation is skipped.","solutions":["If you changed .proto files, delete generated files (find apache_beam -name '*_pb2*.py' -delete and *_pb2_grpc.py) and re-run generation.","Run gen_protos.py directly with --force to regenerate regardless of existing outputs.","If skipping is intended, ignore the warning — generated protos are already present."],"exampleFix":"// before\n$ python setup.py generate_protos_first   # warns, skips\n// after\n$ find apache_beam -name '*_pb2*.py' -delete\n$ python setup.py generate_protos_first","handlingStrategy":"validation","validationCode":"import glob, subprocess, sys, os\nif glob.glob('apache_beam/**/*_pb2.py', recursive=True):\n    subprocess.run([sys.executable, 'gen_protos.py', '--force'], check=True)  # regenerate after .proto edits","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Delete *_pb2*.py files whenever you edit .proto sources","Use gen_protos.py --force for deterministic regeneration","Don't commit generated pb2 files into your working tree"],"tags":["python","protobuf","codegen","build"],"backgroundTag":"codegen-skipped","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"}