From 7897928296977db090bdf41b08bf4b395a3fea80 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Tue, 25 Feb 2025 07:39:32 +0000
Subject: [PATCH 1/7] Update dependency botocore to v1.37.0

---
 requirements-test.txt | 6 +++---
 requirements.txt      | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/requirements-test.txt b/requirements-test.txt
index 8a0f8945..ba19e0f5 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -32,9 +32,9 @@ boto3==1.36.26 \
     --hash=sha256:523b69457eee55ac15aa707c0e768b2a45ca1521f95b2442931090633ec72458 \
     --hash=sha256:f67d014a7c5a3cd540606d64d7cb9eec3600cf42acab1ac0518df9751ae115e2
     # via -r requirements.txt
-botocore==1.36.26 \
-    --hash=sha256:4a63bcef7ecf6146fd3a61dc4f9b33b7473b49bdaf1770e9aaca6eee0c9eab62 \
-    --hash=sha256:4e3f19913887a58502e71ef8d696fe7eaa54de7813ff73390cd5883f837dfa6e
+botocore==1.37.0 \
+    --hash=sha256:b129d091a8360b4152ab65327186bf4e250de827c4a9b7ddf40a72b1acf1f3c1 \
+    --hash=sha256:d01661f38c0edac87424344cdf4169f3ab9bc1bf1b677c8b230d025eb66c54a3
     # via
     #   -r requirements.txt
     #   boto3
diff --git a/requirements.txt b/requirements.txt
index 56153a1b..25f5dee0 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -24,9 +24,9 @@ boto3==1.36.26 \
     --hash=sha256:523b69457eee55ac15aa707c0e768b2a45ca1521f95b2442931090633ec72458 \
     --hash=sha256:f67d014a7c5a3cd540606d64d7cb9eec3600cf42acab1ac0518df9751ae115e2
     # via iib (setup.py)
-botocore==1.36.26 \
-    --hash=sha256:4a63bcef7ecf6146fd3a61dc4f9b33b7473b49bdaf1770e9aaca6eee0c9eab62 \
-    --hash=sha256:4e3f19913887a58502e71ef8d696fe7eaa54de7813ff73390cd5883f837dfa6e
+botocore==1.37.0 \
+    --hash=sha256:b129d091a8360b4152ab65327186bf4e250de827c4a9b7ddf40a72b1acf1f3c1 \
+    --hash=sha256:d01661f38c0edac87424344cdf4169f3ab9bc1bf1b677c8b230d025eb66c54a3
     # via
     #   boto3
     #   s3transfer

From eed868a2d70b5e8c97a5f12217d44b3b1d4132d0 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Tue, 25 Feb 2025 16:08:25 +0000
Subject: [PATCH 2/7] Update dependency boto3 to v1.37.0

---
 requirements-test.txt | 6 +++---
 requirements.txt      | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/requirements-test.txt b/requirements-test.txt
index ba19e0f5..9dc98599 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -28,9 +28,9 @@ blinker==1.9.0 \
     # via
     #   -r requirements.txt
     #   flask
-boto3==1.36.26 \
-    --hash=sha256:523b69457eee55ac15aa707c0e768b2a45ca1521f95b2442931090633ec72458 \
-    --hash=sha256:f67d014a7c5a3cd540606d64d7cb9eec3600cf42acab1ac0518df9751ae115e2
+boto3==1.37.0 \
+    --hash=sha256:01015b38017876d79efd7273f35d9a4adfba505237159621365bed21b9b65eca \
+    --hash=sha256:03bd8c93b226f07d944fd6b022e11a307bff94ab6a21d51675d7e3ea81ee8424
     # via -r requirements.txt
 botocore==1.37.0 \
     --hash=sha256:b129d091a8360b4152ab65327186bf4e250de827c4a9b7ddf40a72b1acf1f3c1 \
diff --git a/requirements.txt b/requirements.txt
index 25f5dee0..f54310c9 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -20,9 +20,9 @@ blinker==1.9.0 \
     --hash=sha256:b4ce2265a7abece45e7cc896e98dbebe6cead56bcf805a3d23136d145f5445bf \
     --hash=sha256:ba0efaa9080b619ff2f3459d1d500c57bddea4a6b424b60a91141db6fd2f08bc
     # via flask
-boto3==1.36.26 \
-    --hash=sha256:523b69457eee55ac15aa707c0e768b2a45ca1521f95b2442931090633ec72458 \
-    --hash=sha256:f67d014a7c5a3cd540606d64d7cb9eec3600cf42acab1ac0518df9751ae115e2
+boto3==1.37.0 \
+    --hash=sha256:01015b38017876d79efd7273f35d9a4adfba505237159621365bed21b9b65eca \
+    --hash=sha256:03bd8c93b226f07d944fd6b022e11a307bff94ab6a21d51675d7e3ea81ee8424
     # via iib (setup.py)
 botocore==1.37.0 \
     --hash=sha256:b129d091a8360b4152ab65327186bf4e250de827c4a9b7ddf40a72b1acf1f3c1 \

From 5572ee280ab175a35203d5e47586874f6817afb1 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Tue, 25 Feb 2025 16:18:38 +0000
Subject: [PATCH 3/7] Update dependency setuptools to v75.8.1

---
 requirements-test.txt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/requirements-test.txt b/requirements-test.txt
index 9dc98599..8a1fadbf 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -1260,9 +1260,9 @@ zipp==3.21.0 \
     #   importlib-metadata
 
 # The following packages are considered to be unsafe in a requirements file:
-setuptools==75.8.0 \
-    --hash=sha256:c5afc8f407c626b8313a86e10311dd3f661c6cd9c09d4bf8c15c0e11f9f2b0e6 \
-    --hash=sha256:e3982f444617239225d675215d51f6ba05f845d4eec313da4418fdbb56fb27e3
+setuptools==75.8.1 \
+    --hash=sha256:3bc32c0b84c643299ca94e77f834730f126efd621de0cc1de64119e0e17dab1f \
+    --hash=sha256:65fb779a8f28895242923582eadca2337285f0891c2c9e160754df917c3d2530
     # via
     #   -r requirements-test.in
     #   pbr

From 99d69133178e59593a204bb3582a80046768bca3 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Tue, 25 Feb 2025 21:40:05 +0000
Subject: [PATCH 4/7] Update dependency botocore to v1.37.1

---
 requirements-test.txt | 6 +++---
 requirements.txt      | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/requirements-test.txt b/requirements-test.txt
index 8a1fadbf..98328bdf 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -32,9 +32,9 @@ boto3==1.37.0 \
     --hash=sha256:01015b38017876d79efd7273f35d9a4adfba505237159621365bed21b9b65eca \
     --hash=sha256:03bd8c93b226f07d944fd6b022e11a307bff94ab6a21d51675d7e3ea81ee8424
     # via -r requirements.txt
-botocore==1.37.0 \
-    --hash=sha256:b129d091a8360b4152ab65327186bf4e250de827c4a9b7ddf40a72b1acf1f3c1 \
-    --hash=sha256:d01661f38c0edac87424344cdf4169f3ab9bc1bf1b677c8b230d025eb66c54a3
+botocore==1.37.1 \
+    --hash=sha256:b194db8fb2a0ffba53568c364ae26166e7eec0445496b2ac86a6e142f3dd982f \
+    --hash=sha256:c1db1bfc5d8c6b3b6d1ca6794f605294b4264e82a7e727b88e0fef9c2b9fbb9c
     # via
     #   -r requirements.txt
     #   boto3
diff --git a/requirements.txt b/requirements.txt
index f54310c9..5f70f0a4 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -24,9 +24,9 @@ boto3==1.37.0 \
     --hash=sha256:01015b38017876d79efd7273f35d9a4adfba505237159621365bed21b9b65eca \
     --hash=sha256:03bd8c93b226f07d944fd6b022e11a307bff94ab6a21d51675d7e3ea81ee8424
     # via iib (setup.py)
-botocore==1.37.0 \
-    --hash=sha256:b129d091a8360b4152ab65327186bf4e250de827c4a9b7ddf40a72b1acf1f3c1 \
-    --hash=sha256:d01661f38c0edac87424344cdf4169f3ab9bc1bf1b677c8b230d025eb66c54a3
+botocore==1.37.1 \
+    --hash=sha256:b194db8fb2a0ffba53568c364ae26166e7eec0445496b2ac86a6e142f3dd982f \
+    --hash=sha256:c1db1bfc5d8c6b3b6d1ca6794f605294b4264e82a7e727b88e0fef9c2b9fbb9c
     # via
     #   boto3
     #   s3transfer

From 438b2caaa1660532210bd9fccd0ebf9ccfa7ac99 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Wed, 26 Feb 2025 19:23:49 +0000
Subject: [PATCH 5/7] Update dependency boto3 to v1.37.1

---
 requirements-test.txt | 6 +++---
 requirements.txt      | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/requirements-test.txt b/requirements-test.txt
index 98328bdf..788272a6 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -28,9 +28,9 @@ blinker==1.9.0 \
     # via
     #   -r requirements.txt
     #   flask
-boto3==1.37.0 \
-    --hash=sha256:01015b38017876d79efd7273f35d9a4adfba505237159621365bed21b9b65eca \
-    --hash=sha256:03bd8c93b226f07d944fd6b022e11a307bff94ab6a21d51675d7e3ea81ee8424
+boto3==1.37.1 \
+    --hash=sha256:4320441f904435a1b85e6ecb81793192e522c737cc9ed6566014e29f0a11cb22 \
+    --hash=sha256:96d18f7feb0c1fcb95f8837b74b6c8880e1b4e35ce5f8a8f8cb243a090c278ed
     # via -r requirements.txt
 botocore==1.37.1 \
     --hash=sha256:b194db8fb2a0ffba53568c364ae26166e7eec0445496b2ac86a6e142f3dd982f \
diff --git a/requirements.txt b/requirements.txt
index 5f70f0a4..09a8be8c 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -20,9 +20,9 @@ blinker==1.9.0 \
     --hash=sha256:b4ce2265a7abece45e7cc896e98dbebe6cead56bcf805a3d23136d145f5445bf \
     --hash=sha256:ba0efaa9080b619ff2f3459d1d500c57bddea4a6b424b60a91141db6fd2f08bc
     # via flask
-boto3==1.37.0 \
-    --hash=sha256:01015b38017876d79efd7273f35d9a4adfba505237159621365bed21b9b65eca \
-    --hash=sha256:03bd8c93b226f07d944fd6b022e11a307bff94ab6a21d51675d7e3ea81ee8424
+boto3==1.37.1 \
+    --hash=sha256:4320441f904435a1b85e6ecb81793192e522c737cc9ed6566014e29f0a11cb22 \
+    --hash=sha256:96d18f7feb0c1fcb95f8837b74b6c8880e1b4e35ce5f8a8f8cb243a090c278ed
     # via iib (setup.py)
 botocore==1.37.1 \
     --hash=sha256:b194db8fb2a0ffba53568c364ae26166e7eec0445496b2ac86a6e142f3dd982f \

From 8aae6027fc338d80a368a326eac3005493a23943 Mon Sep 17 00:00:00 2001
From: Ashwini Kumar <ashwkuma@redhat.com>
Date: Tue, 4 Feb 2025 19:50:58 +0530
Subject: [PATCH 6/7] CLOUDDST-24254 : Merge index image failing with FBC
 operator present in source This commit fix this bug by ignoring deprecation
 operators which are not available in database.

---
 iib/workers/tasks/build_merge_index_image.py  | 10 ++++
 iib/workers/tasks/utils.py                    | 26 ++++++++
 .../test_build_merge_index_image.py           | 15 ++++-
 tests/test_workers/test_tasks/test_utils.py   | 59 +++++++++++++++++++
 4 files changed, 109 insertions(+), 1 deletion(-)

diff --git a/iib/workers/tasks/build_merge_index_image.py b/iib/workers/tasks/build_merge_index_image.py
index 6e0c2cf3..81d67ea9 100644
--- a/iib/workers/tasks/build_merge_index_image.py
+++ b/iib/workers/tasks/build_merge_index_image.py
@@ -39,6 +39,7 @@
 from iib.workers.tasks.utils import (
     add_max_ocp_version_property,
     chmod_recursively,
+    filter_operators_present_in_db,
     get_bundles_from_deprecation_list,
     request_logger,
     set_registry_token,
@@ -326,6 +327,15 @@ def handle_merge_request(
             bundle['bundlePath'] for bundle in invalid_version_bundles
         ]
 
+        index_db_file = os.path.join(temp_dir, get_worker_config()['temp_index_db_path'])
+
+        # Operator passed in deprecation list should be available in operator database,
+        # filter_operators_present_in_db removes operaors which are passed in
+        # deprecation list and does not exists in database.
+        deprecation_bundles = filter_operators_present_in_db(
+            deprecation_bundles, index_db_file, temp_dir
+        )
+
         if deprecation_bundles:
             intermediate_image_name = _get_external_arch_pull_spec(
                 request_id, arch, include_transport=False
diff --git a/iib/workers/tasks/utils.py b/iib/workers/tasks/utils.py
index 05499d6b..bf6a82fa 100644
--- a/iib/workers/tasks/utils.py
+++ b/iib/workers/tasks/utils.py
@@ -1265,3 +1265,29 @@ def get_bundle_metadata(
         for pullspec in operator_csv.get_pullspecs():
             bundle_metadata['found_pullspecs'].add(pullspec)
     return bundle_metadata
+
+
+def filter_operators_present_in_db(
+    deprecation_bundles: List[str],
+    index_db_file: str,
+    temp_dir: str,
+) -> List[str]:
+    """
+    Check if operator marked for deprecation is available, if not drop them.
+
+    :param List[str] deprecation_bundles: List of bundles to be depricated
+    :param str index_db_file: Path of operator database
+    :param str temp_dir: temp directory where opm will be executed
+
+    :return:rtype: list(str) A List of operator bundle to be deprecated
+    """
+    bundles_list = get_list_bundles(index_db_file, temp_dir)
+
+    deprecation_bundles = [
+        bundle["bundlePath"]
+        for bundle in bundles_list
+        if bundle["bundlePath"] in deprecation_bundles
+    ]
+
+    log.info("Deprecation bundle after filter is : %s", deprecation_bundles)
+    return deprecation_bundles
diff --git a/tests/test_workers/test_tasks/test_build_merge_index_image.py b/tests/test_workers/test_tasks/test_build_merge_index_image.py
index a63e287c..3e85b5c7 100644
--- a/tests/test_workers/test_tasks/test_build_merge_index_image.py
+++ b/tests/test_workers/test_tasks/test_build_merge_index_image.py
@@ -29,6 +29,7 @@
 @mock.patch('iib.workers.tasks.build_merge_index_image._push_image')
 @mock.patch('iib.workers.tasks.build_merge_index_image._build_image')
 @mock.patch('iib.workers.tasks.build_merge_index_image.deprecate_bundles_fbc')
+@mock.patch('iib.workers.tasks.build_merge_index_image.filter_operators_present_in_db')
 @mock.patch('iib.workers.tasks.build_merge_index_image.deprecate_bundles')
 @mock.patch('iib.workers.tasks.build_merge_index_image._get_external_arch_pull_spec')
 @mock.patch('iib.workers.tasks.build_merge_index_image.get_bundles_from_deprecation_list')
@@ -63,6 +64,7 @@ def test_handle_merge_request(
     mock_gbfdl,
     mock_geaps,
     mock_dep_b,
+    mock_f_dep_b,
     mock_dep_b_fbc,
     mock_bi,
     mock_pi,
@@ -118,6 +120,7 @@ def side_effect(*args, base_dir, **kwargs):
 
     mock_dep_b.side_effect = side_effect
     mock_dep_b_fbc.side_effect = side_effect
+    mock_f_dep_b.return_value = mock_dep_b
 
     mock_gidp.return_value = '/tmp'
     mock_run_cmd.return_value = json.dumps(
@@ -203,6 +206,7 @@ def side_effect(*args, base_dir, **kwargs):
     return_value=[[{'bundlePath': 'some_bundle'}], []],
 )
 @mock.patch('iib.workers.tasks.utils.set_request_state')
+@mock.patch('iib.workers.tasks.utils.get_list_bundles')
 @mock.patch('iib.workers.tasks.build_merge_index_image.set_request_state')
 @mock.patch('iib.workers.tasks.build_merge_index_image._update_index_image_build_state')
 @mock.patch('iib.workers.tasks.build_merge_index_image.prepare_request_for_build')
@@ -218,6 +222,7 @@ def test_handle_merge_request_no_deprecate(
     mock_prfb,
     mock_uiibs,
     mock_srs,
+    mock_get_bundles,
     mock_srs2,
     mock_gpb,
     mock_abmis,
@@ -261,7 +266,14 @@ def test_handle_merge_request_no_deprecate(
     mock_abmis.return_value = ([], invalid_bundles)
     mock_gid.return_value = 'database/index.db'
     mock_om.return_value = 'catalog', 'cache'
-
+    mock_get_bundles.return_value = [
+        {
+            'bundlePath': 'invalid_bundle:1.0',
+            'csvName': 'invalid_bundle:1.0',
+            'packageName': 'invalid_bundle',
+            'version': '1.0',
+        },
+    ]
     mock_run_cmd.return_value = json.dumps(
         {
             "schema": "olm.bundle",
@@ -309,6 +321,7 @@ def test_handle_merge_request_no_deprecate(
                 binary_image='binary-image:1.0',
                 from_index=mock.ANY,
             )
+            mock_get_bundles.assert_called_once()
             assert mock_bi.call_count == 2
             assert mock_pi.call_count == 2
         else:
diff --git a/tests/test_workers/test_tasks/test_utils.py b/tests/test_workers/test_tasks/test_utils.py
index a07e9756..c720c97d 100644
--- a/tests/test_workers/test_tasks/test_utils.py
+++ b/tests/test_workers/test_tasks/test_utils.py
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-3.0-or-later
 import logging
 import os
+
 import stat
 import textwrap
 from unittest import mock
@@ -1264,3 +1265,61 @@ def test_add_max_ocp_version_property_empty_index(mock_apti, mock_glb, mock_gbj,
 
     mock_gbj.assert_not_called()
     mock_apti.assert_not_called()
+
+
+@mock.patch('iib.workers.tasks.utils.get_list_bundles')
+def filter_operators_present_in_db(mock_bundle_list):
+
+    mock_bundle_list.return_value = [
+        {
+            'bundlePath': 'op1@sha',
+            'csvName': 'op1.v0.1.489-1',
+            'packageName': 'op1',
+            'version': '0.1.489-1',
+        },
+        {
+            'bundlePath': 'op2@sha',
+            'csvName': 'op2.v0.1.501-1',
+            'packageName': 'op2',
+            'version': '0.1.501-1',
+        },
+    ]
+
+    deprecation_bundles = [
+        "op1@sha",
+    ]
+
+    operator_after_deprication = utils.filter_operators_present_in_db(
+        deprecation_bundles, "index/db/file", "temp_dir"
+    )
+
+    assert operator_after_deprication == ["op1@sha"]
+
+
+@mock.patch('iib.workers.tasks.utils.get_list_bundles')
+def test_no_matching_filter_operators_present_in_db(mock_bundle_list):
+
+    mock_bundle_list.return_value = [
+        {
+            'bundlePath': 'op1@sha',
+            'csvName': 'op1.v0.1.489-1',
+            'packageName': 'op1',
+            'version': '0.1.489-1',
+        },
+        {
+            'bundlePath': 'op2@sha',
+            'csvName': 'op2.v0.1.501-1',
+            'packageName': 'op2',
+            'version': '0.1.501-1',
+        },
+    ]
+
+    deprecation_bundles = [
+        "op3@sha",
+    ]
+
+    operator_after_deprication = utils.filter_operators_present_in_db(
+        deprecation_bundles, "index/db/file", "temp_dir"
+    )
+
+    assert operator_after_deprication == []

From c57f6ed890803210502277dbb14e5b2c7e9ba03d Mon Sep 17 00:00:00 2001
From: Ashwini Kumar <ashwkuma@redhat.com>
Date: Tue, 25 Feb 2025 01:15:22 +0530
Subject: [PATCH 7/7] updating it to use pre-existing verify_operators_exists

---
 iib/workers/tasks/build_merge_index_image.py  | 36 +++++++----
 iib/workers/tasks/utils.py                    | 26 --------
 .../test_build_merge_index_image.py           | 17 +++---
 tests/test_workers/test_tasks/test_utils.py   | 59 -------------------
 4 files changed, 33 insertions(+), 105 deletions(-)

diff --git a/iib/workers/tasks/build_merge_index_image.py b/iib/workers/tasks/build_merge_index_image.py
index 81d67ea9..052a9729 100644
--- a/iib/workers/tasks/build_merge_index_image.py
+++ b/iib/workers/tasks/build_merge_index_image.py
@@ -16,6 +16,7 @@
     deprecate_bundles_fbc,
     opm_index_add,
     deprecate_bundles,
+    verify_operators_exists,
     Opm,
 )
 from packaging.version import Version
@@ -39,7 +40,6 @@
 from iib.workers.tasks.utils import (
     add_max_ocp_version_property,
     chmod_recursively,
-    filter_operators_present_in_db,
     get_bundles_from_deprecation_list,
     request_logger,
     set_registry_token,
@@ -317,30 +317,40 @@ def handle_merge_request(
         set_request_state(request_id, 'in_progress', 'Deprecating bundles in the deprecation list')
         log.info('Deprecating bundles in the deprecation list')
         intermediate_bundles = missing_bundle_paths + source_index_bundles_pull_spec
+
         deprecation_bundles = get_bundles_from_deprecation_list(
             intermediate_bundles, deprecation_list
         )
+
         # We do not need to pass the invalid_version_bundles through the
         # get_bundles_from_deprecation_list function because we already know
         # they are present in the newly created index.
-        deprecation_bundles = deprecation_bundles + [
-            bundle['bundlePath'] for bundle in invalid_version_bundles
+
+        invalid_version_bundles_names = [
+            bundle["packageName"] for bundle in invalid_version_bundles
         ]
 
-        index_db_file = os.path.join(temp_dir, get_worker_config()['temp_index_db_path'])
+        intermediate_image_name = _get_external_arch_pull_spec(
+            request_id, arch, include_transport=False
+        )
+        filtered_invalid_version_bundles_names, _ = verify_operators_exists(
+            from_index=intermediate_image_name,
+            base_dir=temp_dir,
+            operator_packages=invalid_version_bundles_names,
+            overwrite_from_index_token=None,
+        )
 
         # Operator passed in deprecation list should be available in operator database,
-        # filter_operators_present_in_db removes operaors which are passed in
-        # deprecation list and does not exists in database.
-        deprecation_bundles = filter_operators_present_in_db(
-            deprecation_bundles, index_db_file, temp_dir
-        )
+        invalid_version_bundles = [
+            bundle
+            for bundle in invalid_version_bundles
+            if bundle["packageName"] in list(filtered_invalid_version_bundles_names)
+        ]
+        deprecation_bundles = deprecation_bundles + [
+            bundle['bundlePath'] for bundle in invalid_version_bundles
+        ]
 
         if deprecation_bundles:
-            intermediate_image_name = _get_external_arch_pull_spec(
-                request_id, arch, include_transport=False
-            )
-
             # we can check if source index is FBC or not because intermediate_image
             # will be always the same type because it is built
             # from source index image in _add_bundles_missing_in_source()
diff --git a/iib/workers/tasks/utils.py b/iib/workers/tasks/utils.py
index bf6a82fa..05499d6b 100644
--- a/iib/workers/tasks/utils.py
+++ b/iib/workers/tasks/utils.py
@@ -1265,29 +1265,3 @@ def get_bundle_metadata(
         for pullspec in operator_csv.get_pullspecs():
             bundle_metadata['found_pullspecs'].add(pullspec)
     return bundle_metadata
-
-
-def filter_operators_present_in_db(
-    deprecation_bundles: List[str],
-    index_db_file: str,
-    temp_dir: str,
-) -> List[str]:
-    """
-    Check if operator marked for deprecation is available, if not drop them.
-
-    :param List[str] deprecation_bundles: List of bundles to be depricated
-    :param str index_db_file: Path of operator database
-    :param str temp_dir: temp directory where opm will be executed
-
-    :return:rtype: list(str) A List of operator bundle to be deprecated
-    """
-    bundles_list = get_list_bundles(index_db_file, temp_dir)
-
-    deprecation_bundles = [
-        bundle["bundlePath"]
-        for bundle in bundles_list
-        if bundle["bundlePath"] in deprecation_bundles
-    ]
-
-    log.info("Deprecation bundle after filter is : %s", deprecation_bundles)
-    return deprecation_bundles
diff --git a/tests/test_workers/test_tasks/test_build_merge_index_image.py b/tests/test_workers/test_tasks/test_build_merge_index_image.py
index 3e85b5c7..f797ba77 100644
--- a/tests/test_workers/test_tasks/test_build_merge_index_image.py
+++ b/tests/test_workers/test_tasks/test_build_merge_index_image.py
@@ -29,7 +29,7 @@
 @mock.patch('iib.workers.tasks.build_merge_index_image._push_image')
 @mock.patch('iib.workers.tasks.build_merge_index_image._build_image')
 @mock.patch('iib.workers.tasks.build_merge_index_image.deprecate_bundles_fbc')
-@mock.patch('iib.workers.tasks.build_merge_index_image.filter_operators_present_in_db')
+@mock.patch('iib.workers.tasks.build_merge_index_image.verify_operators_exists')
 @mock.patch('iib.workers.tasks.build_merge_index_image.deprecate_bundles')
 @mock.patch('iib.workers.tasks.build_merge_index_image._get_external_arch_pull_spec')
 @mock.patch('iib.workers.tasks.build_merge_index_image.get_bundles_from_deprecation_list')
@@ -64,7 +64,7 @@ def test_handle_merge_request(
     mock_gbfdl,
     mock_geaps,
     mock_dep_b,
-    mock_f_dep_b,
+    mock_verify_operator_exits,
     mock_dep_b_fbc,
     mock_bi,
     mock_pi,
@@ -120,7 +120,7 @@ def side_effect(*args, base_dir, **kwargs):
 
     mock_dep_b.side_effect = side_effect
     mock_dep_b_fbc.side_effect = side_effect
-    mock_f_dep_b.return_value = mock_dep_b
+    mock_verify_operator_exits.return_value = (mock_dep_b, "")
 
     mock_gidp.return_value = '/tmp'
     mock_run_cmd.return_value = json.dumps(
@@ -185,7 +185,9 @@ def side_effect(*args, base_dir, **kwargs):
 
 
 @pytest.mark.parametrize('source_fbc, target_fbc', [(False, False), (False, True), (True, True)])
-@pytest.mark.parametrize('invalid_bundles', ([], [{'bundlePath': 'invalid_bundle:1.0'}]))
+@pytest.mark.parametrize(
+    'invalid_bundles', ([], [{'bundlePath': 'invalid_bundle:1.0', "packageName": "invalid_bundle"}])
+)
 @mock.patch('iib.workers.tasks.opm_operations._get_input_data_path')
 @mock.patch('iib.workers.tasks.utils.run_cmd')
 @mock.patch('iib.workers.tasks.build_merge_index_image._update_index_image_pull_spec')
@@ -206,7 +208,7 @@ def side_effect(*args, base_dir, **kwargs):
     return_value=[[{'bundlePath': 'some_bundle'}], []],
 )
 @mock.patch('iib.workers.tasks.utils.set_request_state')
-@mock.patch('iib.workers.tasks.utils.get_list_bundles')
+@mock.patch('iib.workers.tasks.opm_operations.get_list_bundles')
 @mock.patch('iib.workers.tasks.build_merge_index_image.set_request_state')
 @mock.patch('iib.workers.tasks.build_merge_index_image._update_index_image_build_state')
 @mock.patch('iib.workers.tasks.build_merge_index_image.prepare_request_for_build')
@@ -214,7 +216,9 @@ def side_effect(*args, base_dir, **kwargs):
 @mock.patch('iib.workers.tasks.build_merge_index_image._add_label_to_index')
 @mock.patch('iib.workers.tasks.build_merge_index_image.is_image_fbc')
 @mock.patch('iib.workers.tasks.opm_operations.Opm.set_opm_version')
+@mock.patch('iib.workers.tasks.opm_operations.get_hidden_index_database')
 def test_handle_merge_request_no_deprecate(
+    mock_get_hidden_db,
     mock_sov,
     mock_iifbc,
     mock_add_label_to_index,
@@ -313,6 +317,7 @@ def test_handle_merge_request_no_deprecate(
     assert mock_gpb.call_count == 2
     mock_abmis.assert_called_once()
     mock_gbfdl.assert_called_once()
+    mock_geaps.assert_called_once()
     if invalid_bundles:
         if source_fbc:
             mock_dep_b_fbc.assert_called_once_with(
@@ -334,9 +339,7 @@ def test_handle_merge_request_no_deprecate(
             )
             assert mock_bi.call_count == 3
             assert mock_pi.call_count == 3
-        mock_geaps.assert_called_once()
     else:
-        mock_geaps.assert_not_called()
         mock_dep_b.assert_not_called()
         mock_dep_b_fbc.assert_not_called()
         assert mock_bi.call_count == 2
diff --git a/tests/test_workers/test_tasks/test_utils.py b/tests/test_workers/test_tasks/test_utils.py
index c720c97d..a07e9756 100644
--- a/tests/test_workers/test_tasks/test_utils.py
+++ b/tests/test_workers/test_tasks/test_utils.py
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-3.0-or-later
 import logging
 import os
-
 import stat
 import textwrap
 from unittest import mock
@@ -1265,61 +1264,3 @@ def test_add_max_ocp_version_property_empty_index(mock_apti, mock_glb, mock_gbj,
 
     mock_gbj.assert_not_called()
     mock_apti.assert_not_called()
-
-
-@mock.patch('iib.workers.tasks.utils.get_list_bundles')
-def filter_operators_present_in_db(mock_bundle_list):
-
-    mock_bundle_list.return_value = [
-        {
-            'bundlePath': 'op1@sha',
-            'csvName': 'op1.v0.1.489-1',
-            'packageName': 'op1',
-            'version': '0.1.489-1',
-        },
-        {
-            'bundlePath': 'op2@sha',
-            'csvName': 'op2.v0.1.501-1',
-            'packageName': 'op2',
-            'version': '0.1.501-1',
-        },
-    ]
-
-    deprecation_bundles = [
-        "op1@sha",
-    ]
-
-    operator_after_deprication = utils.filter_operators_present_in_db(
-        deprecation_bundles, "index/db/file", "temp_dir"
-    )
-
-    assert operator_after_deprication == ["op1@sha"]
-
-
-@mock.patch('iib.workers.tasks.utils.get_list_bundles')
-def test_no_matching_filter_operators_present_in_db(mock_bundle_list):
-
-    mock_bundle_list.return_value = [
-        {
-            'bundlePath': 'op1@sha',
-            'csvName': 'op1.v0.1.489-1',
-            'packageName': 'op1',
-            'version': '0.1.489-1',
-        },
-        {
-            'bundlePath': 'op2@sha',
-            'csvName': 'op2.v0.1.501-1',
-            'packageName': 'op2',
-            'version': '0.1.501-1',
-        },
-    ]
-
-    deprecation_bundles = [
-        "op3@sha",
-    ]
-
-    operator_after_deprication = utils.filter_operators_present_in_db(
-        deprecation_bundles, "index/db/file", "temp_dir"
-    )
-
-    assert operator_after_deprication == []