prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Greenwave consumer should not process the compose results
  Currently the greenwave consumer consumes all the messages from `topic=org.fedoraproject.prod.greenwave.decision.update` but some messages on this topic are related to compose results and not koji build.
  
  The consumer should filter the messages based on the `subject_type`, and only process `koji_build` type.
  
  See a koji_build example https://apps.fedoraproject.org/datagrepper/id?id=2019-efb310ed-6acf-4742-809f-90a40c2a5855&is_raw=true&size=extra-large
  
  And a compose example https://apps.fedoraproject.org/datagrepper/id?id=2019-33002e05-241c-4180-8953-5a29cea4443d&is_raw=true&size=extra-large
  
  This is currently raising the following exception in production : 
  ``` 2019-07-26 15:16:55,501 ERROR [bodhi.server][PoolThread-twisted.internet.reactor-0] Bodhi failed to send POST request to Greenwave at the following URL "https://greenwave-web-greenwave.app.os.fedoraproject.org/api/v1.0/decision". The status code was "502". The error was "{'message': 'Failed to retrieve SCM URL from Koji build "Fedora-Workstation-Rawhide-20190726.n.0" at "https://koji.fedoraproject.org/kojihub" (expected SCM URL in "source" attribute)'}". ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `bodhi/server/consumers/greenwave.py`
  Content:
  ```
  1 # Copyright © 2019 Red Hat, Inc.
  2 #
  3 # This file is part of Bodhi.
  4 #
  5 # This program is free software; you can redistribute it and/or
  6 # modify it under the terms of the GNU General Public License
  7 # as published by the Free Software Foundation; either version 2
  8 # of the License, or (at your option) any later version.
  9 #
  10 # This program is distributed in the hope that it will be useful,
  11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13 # GNU General Public License for more details.
  14 #
  15 # You should have received a copy of the GNU General Public License along with
  16 # this program; if not, write to the Free Software Foundation, Inc., 51
  17 # Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  18 """
  19 The "greenwave handler".
  20 
  21 This module is responsible for listening for messages from greenwave.
  22 It then updates the policies of the build that greenwave checked.
  23 """
  24 
  25 import logging
  26 
  27 import fedora_messaging
  28 
  29 from bodhi.server.models import Build
  30 from bodhi.server.util import transactional_session_maker
  31 
  32 log = logging.getLogger(__name__)
  33 
  34 
  35 class GreenwaveHandler:
  36     """
  37     The Bodhi Greenwave Handler.
  38 
  39     A fedora-messaging listener waiting for messages from greenwave about enforced policies.
  40     """
  41 
  42     def __init__(self):
  43         """Initialize the GreenwaveHandler."""
  44         self.db_factory = transactional_session_maker()
  45 
  46     def __call__(self, message: fedora_messaging.api.Message):
  47         """Handle messages arriving with the configured topic."""
  48         msg = message.body
  49         if not msg:
  50             log.debug("Ignoring message without body.")
  51             return
  52 
  53         subject_identifier = msg.get("subject_identifier")
  54 
  55         if subject_identifier is None:
  56             log.debug("Couldn't find subject_identifier in Greenwave message")
  57             return
  58 
  59         with self.db_factory():
  60 
  61             build = Build.get(subject_identifier)
  62             if build is None:
  63                 log.debug(f"Couldn't find build {subject_identifier} in DB")
  64                 return
  65 
  66             log.info(f"Updating the test_gating_status for: {build.update.alias}")
  67             build.update.update_test_gating_status()
  68
  ```
  --- 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/bodhi/server/consumers/greenwave.py b/bodhi/server/consumers/greenwave.py
  --- a/bodhi/server/consumers/greenwave.py
  +++ b/bodhi/server/consumers/greenwave.py
  @@ -56,6 +56,11 @@
               log.debug("Couldn't find subject_identifier in Greenwave message")
               return
   
  +        subject_type = msg.get("subject_type")
  +        if subject_type == "compose":
  +            log.debug("Not requesting a decision for a compose")
  +            return
  +
           with self.db_factory():
   
               build = Build.get(subject_identifier)
  
verification_info: {"golden_diff": "diff --git a/bodhi/server/consumers/greenwave.py b/bodhi/server/consumers/greenwave.py\n--- a/bodhi/server/consumers/greenwave.py\n+++ b/bodhi/server/consumers/greenwave.py\n@@ -56,6 +56,11 @@\n             log.debug(\"Couldn't find subject_identifier in Greenwave message\")\n             return\n \n+        subject_type = msg.get(\"subject_type\")\n+        if subject_type == \"compose\":\n+            log.debug(\"Not requesting a decision for a compose\")\n+            return\n+\n         with self.db_factory():\n \n             build = Build.get(subject_identifier)\n", "issue": "Greenwave consumer should not process the compose results\nCurrently the greenwave consumer consumes all the messages from `topic=org.fedoraproject.prod.greenwave.decision.update` but some messages on this topic are related to compose results and not koji build.\r\n\r\nThe consumer should filter the messages based on the `subject_type`, and only process `koji_build` type.\r\n\r\nSee a koji_build example https://apps.fedoraproject.org/datagrepper/id?id=2019-efb310ed-6acf-4742-809f-90a40c2a5855&is_raw=true&size=extra-large\r\n\r\nAnd a compose example https://apps.fedoraproject.org/datagrepper/id?id=2019-33002e05-241c-4180-8953-5a29cea4443d&is_raw=true&size=extra-large\r\n\r\nThis is currently raising the following exception in production : \r\n``` 2019-07-26 15:16:55,501 ERROR [bodhi.server][PoolThread-twisted.internet.reactor-0] Bodhi failed to send POST request to Greenwave at the following URL \"https://greenwave-web-greenwave.app.os.fedoraproject.org/api/v1.0/decision\". The status code was \"502\". The error was \"{'message': 'Failed to retrieve SCM URL from Koji build \"Fedora-Workstation-Rawhide-20190726.n.0\" at \"https://koji.fedoraproject.org/kojihub\" (expected SCM URL in \"source\" attribute)'}\". ```\n", "before_files": [{"content": "# Copyright \u00a9 2019 Red Hat, Inc.\n#\n# This file is part of Bodhi.\n#\n# This program is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License\n# as published by the Free Software Foundation; either version 2\n# of the License, or (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License along with\n# this program; if not, write to the Free Software Foundation, Inc., 51\n# Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n\"\"\"\nThe \"greenwave handler\".\n\nThis module is responsible for listening for messages from greenwave.\nIt then updates the policies of the build that greenwave checked.\n\"\"\"\n\nimport logging\n\nimport fedora_messaging\n\nfrom bodhi.server.models import Build\nfrom bodhi.server.util import transactional_session_maker\n\nlog = logging.getLogger(__name__)\n\n\nclass GreenwaveHandler:\n    \"\"\"\n    The Bodhi Greenwave Handler.\n\n    A fedora-messaging listener waiting for messages from greenwave about enforced policies.\n    \"\"\"\n\n    def __init__(self):\n        \"\"\"Initialize the GreenwaveHandler.\"\"\"\n        self.db_factory = transactional_session_maker()\n\n    def __call__(self, message: fedora_messaging.api.Message):\n        \"\"\"Handle messages arriving with the configured topic.\"\"\"\n        msg = message.body\n        if not msg:\n            log.debug(\"Ignoring message without body.\")\n            return\n\n        subject_identifier = msg.get(\"subject_identifier\")\n\n        if subject_identifier is None:\n            log.debug(\"Couldn't find subject_identifier in Greenwave message\")\n            return\n\n        with self.db_factory():\n\n            build = Build.get(subject_identifier)\n            if build is None:\n                log.debug(f\"Couldn't find build {subject_identifier} in DB\")\n                return\n\n            log.info(f\"Updating the test_gating_status for: {build.update.alias}\")\n            build.update.update_test_gating_status()\n", "path": "bodhi/server/consumers/greenwave.py"}], "after_files": [{"content": "# Copyright \u00a9 2019 Red Hat, Inc.\n#\n# This file is part of Bodhi.\n#\n# This program is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License\n# as published by the Free Software Foundation; either version 2\n# of the License, or (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License along with\n# this program; if not, write to the Free Software Foundation, Inc., 51\n# Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n\"\"\"\nThe \"greenwave handler\".\n\nThis module is responsible for listening for messages from greenwave.\nIt then updates the policies of the build that greenwave checked.\n\"\"\"\n\nimport logging\n\nimport fedora_messaging\n\nfrom bodhi.server.models import Build\nfrom bodhi.server.util import transactional_session_maker\n\nlog = logging.getLogger(__name__)\n\n\nclass GreenwaveHandler:\n    \"\"\"\n    The Bodhi Greenwave Handler.\n\n    A fedora-messaging listener waiting for messages from greenwave about enforced policies.\n    \"\"\"\n\n    def __init__(self):\n        \"\"\"Initialize the GreenwaveHandler.\"\"\"\n        self.db_factory = transactional_session_maker()\n\n    def __call__(self, message: fedora_messaging.api.Message):\n        \"\"\"Handle messages arriving with the configured topic.\"\"\"\n        msg = message.body\n        if not msg:\n            log.debug(\"Ignoring message without body.\")\n            return\n\n        subject_identifier = msg.get(\"subject_identifier\")\n\n        if subject_identifier is None:\n            log.debug(\"Couldn't find subject_identifier in Greenwave message\")\n            return\n\n        subject_type = msg.get(\"subject_type\")\n        if subject_type == \"compose\":\n            log.debug(\"Not requesting a decision for a compose\")\n            return\n\n        with self.db_factory():\n\n            build = Build.get(subject_identifier)\n            if build is None:\n                log.debug(f\"Couldn't find build {subject_identifier} in DB\")\n                return\n\n            log.info(f\"Updating the test_gating_status for: {build.update.alias}\")\n            build.update.update_test_gating_status()\n", "path": "bodhi/server/consumers/greenwave.py"}]}