@@ -87,6 +87,7 @@ def package_regex_search(
8787 package_data (dict[str, str]): a dictionary of package names and versions
8888 exp_packge_data (dict[str, str | None]): a dictionary of expected package names and versions
8989 """
90+ not_found_keys = []
9091 for exp_key , exp_value in exp_packge_data .items ():
9192 try :
9293 if exp_value is not None :
@@ -109,6 +110,7 @@ def package_regex_search(
109110 key_found = self .regex_version_data (package_data , key_search , value_search )
110111
111112 if not key_found :
113+ not_found_keys .append (exp_key )
112114 self ._log_event (
113115 EventCategory .APPLICATION ,
114116 f"Package { exp_key } not found in the package list" ,
@@ -120,6 +122,7 @@ def package_regex_search(
120122 "found_version" : None ,
121123 },
122124 )
125+ return not_found_keys
123126
124127 def package_exact_match (
125128 self , package_data : dict [str , str ], exp_packge_data : dict [str , str | None ]
@@ -130,13 +133,16 @@ def package_exact_match(
130133 package_data (dict[str, str]): a dictionary of package names and versions
131134 exp_packge_data (dict[str, str | None]): a dictionary of expected package names and versions
132135 """
136+ not_found_match = []
137+ not_found_version = []
133138 for exp_key , exp_value in exp_packge_data .items ():
134139 self .logger .info (exp_key )
135140 version = package_data .get (exp_key )
136141 if exp_value is None :
137142 # allow any version when expected version is None
138143 if version is None :
139144 # package not found
145+ not_found_version .append ((exp_key , version ))
140146 self ._log_event (
141147 EventCategory .APPLICATION ,
142148 f"Package { exp_key } not found in the package list" ,
@@ -149,6 +155,7 @@ def package_exact_match(
149155 },
150156 )
151157 elif version != exp_value :
158+ not_found_match .append ((exp_key , version ))
152159 self ._log_event (
153160 EventCategory .APPLICATION ,
154161 f"Package { exp_key } Version Mismatch, Expected { exp_key } but found { version } " ,
@@ -160,6 +167,7 @@ def package_exact_match(
160167 "found_version" : version ,
161168 },
162169 )
170+ return not_found_match , not_found_version
163171
164172 def analyze_data (
165173 self , data : PackageDataModel , args : Optional [PackageAnalyzerArgs ] = None
@@ -179,8 +187,15 @@ def analyze_data(
179187 return self .result
180188
181189 if args .regex_match :
182- self .package_regex_search (data .version_info , args .exp_package_ver )
190+ not_found_keys = self .package_regex_search (data .version_info , args .exp_package_ver )
191+ self .result .message = f"Packages not found: { not_found_keys } "
192+ self .result .status = ExecutionStatus .ERROR
183193 else :
184- self .package_exact_match (data .version_info , args .exp_package_ver )
194+ not_found_match , not_found_version = self .package_exact_match (
195+ data .version_info , args .exp_package_ver
196+ )
197+ if not_found_match or not_found_version :
198+ self .result .message = f"Package version missmatched. Missmatched versions: { not_found_match } , not found versions: { not_found_version } "
199+ self .result .status = ExecutionStatus .ERROR
185200
186201 return self .result
0 commit comments