prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [Bug]: Broken UTs on `main` branch
  ### Describe the bug
  
  Seeing failures in these 2 UTs on main branch 
  
  ```
  Run pipenv run coverage run -m pytest --cov=./src --cov-report=xml
  F....................................................................... [ 25%]
  ........................................................................ [ 50%]
  ........................................................................ [ 76%]
  ....................................................................     [100%]
  =================================== FAILURES ===================================
  __________________________ TestRunAssemble.test_main ___________________________
  
  self = <tests.test_run_assemble.TestRunAssemble testMethod=test_main>
  mock_copy = <MagicMock name='copy2' id='140398777086032'>
  mock_temp = <MagicMock name='TemporaryDirectory' id='140398777095120'>
  mock_recorder = <MagicMock name='BundleRecorder' id='140398777104272'>
  mock_bundles = <MagicMock name='Bundles' id='140398777121680'>
  mocks = (<MagicMock name='getcwd' id='140398777147472'>, <MagicMock name='makedirs' id='140398777161040'>, <MagicMock name='chdir' id='140398777178384'>)
  mock_bundle = <MagicMock name='Bundles.create()' id='140398776678672'>
  
      @patch("os.chdir")
      @patch("os.makedirs")
      @patch("os.getcwd", return_value="curdir")
      @patch("argparse._sys.argv", ["run_assemble.py", BUILD_MANIFEST])
      @patch("run_assemble.Bundles", return_value=MagicMock())
      @patch("run_assemble.BundleRecorder", return_value=MagicMock())
      @patch("tempfile.TemporaryDirectory")
      @patch("shutil.copy2")
      def test_main(self, mock_copy, mock_temp, mock_recorder, mock_bundles, *mocks):
          mock_temp.return_value.__enter__.return_value = tempfile.gettempdir()
          mock_bundle = MagicMock(archive_path="path")
          mock_bundles.create.return_value = mock_bundle
      
  >       main()
  
  tests/test_run_assemble.py:47: 
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
  src/run_assemble.py:48: in main
      exit(1)
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
  
  self = Use exit() or Ctrl-D (i.e. EOF) to exit, code = 1
  
      def __call__(self, code=None):
          # Shells like IDLE catch the SystemExit, but listen when their
          # stdin wrapper is closed.
          try:
              sys.stdin.close()
          except:
              pass
  >       raise SystemExit(code)
  E       SystemExit: 1
  
  /opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/_sitebuiltins.py:26: SystemExit
  ------------------------------ Captured log call -------------------------------
  ERROR    root:run_assemble.py:46 No installation script found at path: /home/runner/work/opensearch-build/opensearch-build/release/tar/linux/opensearch-tar-install.sh
  
  ---------- coverage: platform linux, python 3.7.12-final-0 -----------
  Coverage XML written to file coverage.xml
  
  =========================== short test summary info ============================
  FAILED tests/test_run_assemble.py::TestRunAssemble::test_main - SystemExit: 1
  1 failed, 283 passed in 31.93s
  Error: Process completed with exit code 1.
  ```
  
  ### To reproduce
  
  Run ut coverage analysis on repo `opensearch-build`, branch `main`
  
  ```
  pipenv run coverage run -m pytest --cov=./src --cov-report=xml
  ```
  
  ### Expected behavior
  
  No UT failures
  
  ### Screenshots
  
  If applicable, add screenshots to help explain your problem.
  
  ### Host / Environment
  
  _No response_
  
  ### Additional context
  
  _No response_
  
  ### Relevant log output
  
  _No response_
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/run_assemble.py`
  Content:
  ```
  1 #!/usr/bin/env python
  2 
  3 # SPDX-License-Identifier: Apache-2.0
  4 #
  5 # The OpenSearch Contributors require contributions made to
  6 # this file be licensed under the Apache-2.0 license or a
  7 # compatible open source license.
  8 
  9 import argparse
  10 import logging
  11 import os
  12 import shutil
  13 import sys
  14 import tempfile
  15 
  16 from assemble_workflow.bundle_recorder import BundleRecorder
  17 from assemble_workflow.bundles import Bundles
  18 from manifests.build_manifest import BuildManifest
  19 from system import console
  20 
  21 
  22 def main():
  23     parser = argparse.ArgumentParser(description="Assemble an OpenSearch Bundle")
  24     parser.add_argument("manifest", type=argparse.FileType("r"), help="Manifest file.")
  25     parser.add_argument(
  26         "-v",
  27         "--verbose",
  28         help="Show more verbose output.",
  29         action="store_const",
  30         default=logging.INFO,
  31         const=logging.DEBUG,
  32         dest="logging_level",
  33     )
  34     args = parser.parse_args()
  35 
  36     console.configure(level=args.logging_level)
  37 
  38     tarball_installation_script = os.path.realpath(
  39         os.path.join(
  40             os.path.dirname(os.path.abspath(__file__)),
  41             "../release/tar/linux/opensearch-tar-install.sh",
  42         )
  43     )
  44     if not os.path.isfile(tarball_installation_script):
  45         logging.error(
  46             f"No installation script found at path: {tarball_installation_script}"
  47         )
  48         exit(1)
  49 
  50     build_manifest = BuildManifest.from_file(args.manifest)
  51     build = build_manifest.build
  52     artifacts_dir = os.path.dirname(os.path.realpath(args.manifest.name))
  53     output_dir = os.path.join(os.getcwd(), "bundle")
  54     os.makedirs(output_dir, exist_ok=True)
  55 
  56     with tempfile.TemporaryDirectory() as work_dir:
  57         logging.info(
  58             f"Bundling {build.name} ({build.architecture}) into {output_dir} ..."
  59         )
  60 
  61         os.chdir(work_dir)
  62 
  63         bundle_recorder = BundleRecorder(build, output_dir, artifacts_dir)
  64 
  65         bundle = Bundles.create(build_manifest, artifacts_dir, bundle_recorder)
  66 
  67         bundle.install_plugins()
  68         logging.info(f"Installed plugins: {bundle.installed_plugins}")
  69 
  70         # Copy the tar installation script into the bundle
  71         shutil.copy2(
  72             tarball_installation_script,
  73             os.path.join(
  74                 bundle.archive_path, os.path.basename(tarball_installation_script)
  75             ),
  76         )
  77 
  78         #  Save a copy of the manifest inside of the tar
  79         bundle_recorder.write_manifest(bundle.archive_path)
  80         bundle.build_tar(output_dir)
  81 
  82         bundle_recorder.write_manifest(output_dir)
  83 
  84     logging.info("Done.")
  85 
  86 
  87 if __name__ == "__main__":
  88     sys.exit(main())
  89
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/run_assemble.py b/src/run_assemble.py
  --- a/src/run_assemble.py
  +++ b/src/run_assemble.py
  @@ -38,7 +38,7 @@
       tarball_installation_script = os.path.realpath(
           os.path.join(
               os.path.dirname(os.path.abspath(__file__)),
  -            "../release/tar/linux/opensearch-tar-install.sh",
  +            "../scripts/legacy/tar/linux/opensearch-tar-install.sh",
           )
       )
       if not os.path.isfile(tarball_installation_script):
  
verification_info: {"golden_diff": "diff --git a/src/run_assemble.py b/src/run_assemble.py\n--- a/src/run_assemble.py\n+++ b/src/run_assemble.py\n@@ -38,7 +38,7 @@\n     tarball_installation_script = os.path.realpath(\n         os.path.join(\n             os.path.dirname(os.path.abspath(__file__)),\n-            \"../release/tar/linux/opensearch-tar-install.sh\",\n+            \"../scripts/legacy/tar/linux/opensearch-tar-install.sh\",\n         )\n     )\n     if not os.path.isfile(tarball_installation_script):\n", "issue": "[Bug]: Broken UTs on `main` branch\n### Describe the bug\r\n\r\nSeeing failures in these 2 UTs on main branch \r\n\r\n```\r\nRun pipenv run coverage run -m pytest --cov=./src --cov-report=xml\r\nF....................................................................... [ 25%]\r\n........................................................................ [ 50%]\r\n........................................................................ [ 76%]\r\n....................................................................     [100%]\r\n=================================== FAILURES ===================================\r\n__________________________ TestRunAssemble.test_main ___________________________\r\n\r\nself = <tests.test_run_assemble.TestRunAssemble testMethod=test_main>\r\nmock_copy = <MagicMock name='copy2' id='140398777086032'>\r\nmock_temp = <MagicMock name='TemporaryDirectory' id='140398777095120'>\r\nmock_recorder = <MagicMock name='BundleRecorder' id='140398777104272'>\r\nmock_bundles = <MagicMock name='Bundles' id='140398777121680'>\r\nmocks = (<MagicMock name='getcwd' id='140398777147472'>, <MagicMock name='makedirs' id='140398777161040'>, <MagicMock name='chdir' id='140398777178384'>)\r\nmock_bundle = <MagicMock name='Bundles.create()' id='140398776678672'>\r\n\r\n    @patch(\"os.chdir\")\r\n    @patch(\"os.makedirs\")\r\n    @patch(\"os.getcwd\", return_value=\"curdir\")\r\n    @patch(\"argparse._sys.argv\", [\"run_assemble.py\", BUILD_MANIFEST])\r\n    @patch(\"run_assemble.Bundles\", return_value=MagicMock())\r\n    @patch(\"run_assemble.BundleRecorder\", return_value=MagicMock())\r\n    @patch(\"tempfile.TemporaryDirectory\")\r\n    @patch(\"shutil.copy2\")\r\n    def test_main(self, mock_copy, mock_temp, mock_recorder, mock_bundles, *mocks):\r\n        mock_temp.return_value.__enter__.return_value = tempfile.gettempdir()\r\n        mock_bundle = MagicMock(archive_path=\"path\")\r\n        mock_bundles.create.return_value = mock_bundle\r\n    \r\n>       main()\r\n\r\ntests/test_run_assemble.py:47: \r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r\nsrc/run_assemble.py:48: in main\r\n    exit(1)\r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r\n\r\nself = Use exit() or Ctrl-D (i.e. EOF) to exit, code = 1\r\n\r\n    def __call__(self, code=None):\r\n        # Shells like IDLE catch the SystemExit, but listen when their\r\n        # stdin wrapper is closed.\r\n        try:\r\n            sys.stdin.close()\r\n        except:\r\n            pass\r\n>       raise SystemExit(code)\r\nE       SystemExit: 1\r\n\r\n/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/_sitebuiltins.py:26: SystemExit\r\n------------------------------ Captured log call -------------------------------\r\nERROR    root:run_assemble.py:46 No installation script found at path: /home/runner/work/opensearch-build/opensearch-build/release/tar/linux/opensearch-tar-install.sh\r\n\r\n---------- coverage: platform linux, python 3.7.12-final-0 -----------\r\nCoverage XML written to file coverage.xml\r\n\r\n=========================== short test summary info ============================\r\nFAILED tests/test_run_assemble.py::TestRunAssemble::test_main - SystemExit: 1\r\n1 failed, 283 passed in 31.93s\r\nError: Process completed with exit code 1.\r\n```\r\n\r\n### To reproduce\r\n\r\nRun ut coverage analysis on repo `opensearch-build`, branch `main`\r\n\r\n```\r\npipenv run coverage run -m pytest --cov=./src --cov-report=xml\r\n```\r\n\r\n### Expected behavior\r\n\r\nNo UT failures\r\n\r\n### Screenshots\r\n\r\nIf applicable, add screenshots to help explain your problem.\r\n\r\n### Host / Environment\r\n\r\n_No response_\r\n\r\n### Additional context\r\n\r\n_No response_\r\n\r\n### Relevant log output\r\n\r\n_No response_\n", "before_files": [{"content": "#!/usr/bin/env python\n\n# SPDX-License-Identifier: Apache-2.0\n#\n# The OpenSearch Contributors require contributions made to\n# this file be licensed under the Apache-2.0 license or a\n# compatible open source license.\n\nimport argparse\nimport logging\nimport os\nimport shutil\nimport sys\nimport tempfile\n\nfrom assemble_workflow.bundle_recorder import BundleRecorder\nfrom assemble_workflow.bundles import Bundles\nfrom manifests.build_manifest import BuildManifest\nfrom system import console\n\n\ndef main():\n    parser = argparse.ArgumentParser(description=\"Assemble an OpenSearch Bundle\")\n    parser.add_argument(\"manifest\", type=argparse.FileType(\"r\"), help=\"Manifest file.\")\n    parser.add_argument(\n        \"-v\",\n        \"--verbose\",\n        help=\"Show more verbose output.\",\n        action=\"store_const\",\n        default=logging.INFO,\n        const=logging.DEBUG,\n        dest=\"logging_level\",\n    )\n    args = parser.parse_args()\n\n    console.configure(level=args.logging_level)\n\n    tarball_installation_script = os.path.realpath(\n        os.path.join(\n            os.path.dirname(os.path.abspath(__file__)),\n            \"../release/tar/linux/opensearch-tar-install.sh\",\n        )\n    )\n    if not os.path.isfile(tarball_installation_script):\n        logging.error(\n            f\"No installation script found at path: {tarball_installation_script}\"\n        )\n        exit(1)\n\n    build_manifest = BuildManifest.from_file(args.manifest)\n    build = build_manifest.build\n    artifacts_dir = os.path.dirname(os.path.realpath(args.manifest.name))\n    output_dir = os.path.join(os.getcwd(), \"bundle\")\n    os.makedirs(output_dir, exist_ok=True)\n\n    with tempfile.TemporaryDirectory() as work_dir:\n        logging.info(\n            f\"Bundling {build.name} ({build.architecture}) into {output_dir} ...\"\n        )\n\n        os.chdir(work_dir)\n\n        bundle_recorder = BundleRecorder(build, output_dir, artifacts_dir)\n\n        bundle = Bundles.create(build_manifest, artifacts_dir, bundle_recorder)\n\n        bundle.install_plugins()\n        logging.info(f\"Installed plugins: {bundle.installed_plugins}\")\n\n        # Copy the tar installation script into the bundle\n        shutil.copy2(\n            tarball_installation_script,\n            os.path.join(\n                bundle.archive_path, os.path.basename(tarball_installation_script)\n            ),\n        )\n\n        #  Save a copy of the manifest inside of the tar\n        bundle_recorder.write_manifest(bundle.archive_path)\n        bundle.build_tar(output_dir)\n\n        bundle_recorder.write_manifest(output_dir)\n\n    logging.info(\"Done.\")\n\n\nif __name__ == \"__main__\":\n    sys.exit(main())\n", "path": "src/run_assemble.py"}], "after_files": [{"content": "#!/usr/bin/env python\n\n# SPDX-License-Identifier: Apache-2.0\n#\n# The OpenSearch Contributors require contributions made to\n# this file be licensed under the Apache-2.0 license or a\n# compatible open source license.\n\nimport argparse\nimport logging\nimport os\nimport shutil\nimport sys\nimport tempfile\n\nfrom assemble_workflow.bundle_recorder import BundleRecorder\nfrom assemble_workflow.bundles import Bundles\nfrom manifests.build_manifest import BuildManifest\nfrom system import console\n\n\ndef main():\n    parser = argparse.ArgumentParser(description=\"Assemble an OpenSearch Bundle\")\n    parser.add_argument(\"manifest\", type=argparse.FileType(\"r\"), help=\"Manifest file.\")\n    parser.add_argument(\n        \"-v\",\n        \"--verbose\",\n        help=\"Show more verbose output.\",\n        action=\"store_const\",\n        default=logging.INFO,\n        const=logging.DEBUG,\n        dest=\"logging_level\",\n    )\n    args = parser.parse_args()\n\n    console.configure(level=args.logging_level)\n\n    tarball_installation_script = os.path.realpath(\n        os.path.join(\n            os.path.dirname(os.path.abspath(__file__)),\n            \"../scripts/legacy/tar/linux/opensearch-tar-install.sh\",\n        )\n    )\n    if not os.path.isfile(tarball_installation_script):\n        logging.error(\n            f\"No installation script found at path: {tarball_installation_script}\"\n        )\n        exit(1)\n\n    build_manifest = BuildManifest.from_file(args.manifest)\n    build = build_manifest.build\n    artifacts_dir = os.path.dirname(os.path.realpath(args.manifest.name))\n    output_dir = os.path.join(os.getcwd(), \"bundle\")\n    os.makedirs(output_dir, exist_ok=True)\n\n    with tempfile.TemporaryDirectory() as work_dir:\n        logging.info(\n            f\"Bundling {build.name} ({build.architecture}) into {output_dir} ...\"\n        )\n\n        os.chdir(work_dir)\n\n        bundle_recorder = BundleRecorder(build, output_dir, artifacts_dir)\n\n        bundle = Bundles.create(build_manifest, artifacts_dir, bundle_recorder)\n\n        bundle.install_plugins()\n        logging.info(f\"Installed plugins: {bundle.installed_plugins}\")\n\n        # Copy the tar installation script into the bundle\n        shutil.copy2(\n            tarball_installation_script,\n            os.path.join(\n                bundle.archive_path, os.path.basename(tarball_installation_script)\n            ),\n        )\n\n        #  Save a copy of the manifest inside of the tar\n        bundle_recorder.write_manifest(bundle.archive_path)\n        bundle.build_tar(output_dir)\n\n        bundle_recorder.write_manifest(output_dir)\n\n    logging.info(\"Done.\")\n\n\nif __name__ == \"__main__\":\n    sys.exit(main())\n", "path": "src/run_assemble.py"}]}