@@ -198,6 +198,15 @@ def COULD_NOT_VENDOR_ALL_FILES(library, errormessage):
198198 s += "they are excluded from the source tree and ignored in the future."
199199 return s
200200
201+ @staticmethod
202+ def MISSING_COMPONENT (library , filed_bug_id ):
203+ return ("%s specifies the Bugzilla component '%s :: %s', which doesn't exist, so Updatebot "
204+ "filed bug %s in %s :: %s instead.\n \n "
205+ "Please update the bugzilla product and component in %s, and move bug %s to the right component." ) % (
206+ library .yaml_path , library .bugzilla_product , library .bugzilla_component ,
207+ filed_bug_id , FALLBACK_PRODUCT_COMPONENT [0 ], FALLBACK_PRODUCT_COMPONENT [1 ],
208+ library .yaml_path , filed_bug_id )
209+
201210 @staticmethod
202211 def TRY_RUN_SUBMITTED (revision , another = False ):
203212 return "I've submitted a" + ("nother" if another else "" ) + " try run for this commit: https://treeherder.mozilla.org/jobs?repo=try&revision=" + revision
@@ -214,6 +223,21 @@ def is_needinfo_exception(e):
214223 return 'is not currently accepting "needinfo" requests' in str (e )
215224
216225
226+ def is_missing_component_exception (e ):
227+ # fileBug raises Exception(<Bugzilla's JSON error>); code 51 is "object
228+ # does not exist", which also covers e.g. unknown users.
229+ j = e .args [0 ] if e .args else None
230+ return isinstance (j , dict ) and j .get ('code' ) == 51 and \
231+ 'There is no component named' in j .get ('message' , '' )
232+
233+
234+ # Where a bug goes when the component in its moz.yaml doesn't exist, and where
235+ # the follow-up bug asking for the moz.yaml to be fixed goes.
236+ FALLBACK_PRODUCT_COMPONENT = ("Core" , "General" )
237+ UPDATEBOT_PRODUCT_COMPONENT = ("Developer Infrastructure" , "Mach Vendor & Updatebot" )
238+ UPDATEBOT_OWNER_BZ = "tom@mozilla.com"
239+
240+
217241class BugzillaProvider (BaseProvider , INeedsLoggingProvider ):
218242 PROTECTED_LANDING_LINK_PREFIXES = (
219243 "https://hg.mozilla.org/integration/autoland/" ,
@@ -240,19 +264,46 @@ def file_bug(self, library, summary, description, cc_list, needinfo=None, see_al
240264 description = description [0 :65533 - len (suffix )] + suffix
241265
242266 try :
243- bugID = fileBug (self .config ['url' ], self .config ['apikey' ], self .config ['General' ]['ff-version' ],
244- library .bugzilla_product , library .bugzilla_component ,
245- summary , description , cc_list , needinfo , see_also , depends_on , blocks , moco_confidential )
267+ bugID = self ._file_bug (library .bugzilla_product , library .bugzilla_component ,
268+ summary , description , cc_list , needinfo , see_also , depends_on , blocks , moco_confidential )
246269 except Exception as e :
247- if is_needinfo_exception (e ):
248- self .logger .log ("Developer is not accepting needinfos, trying again without..." , level = LogLevel .Info )
249- return self .file_bug (library , summary , description , cc_list , None , see_also , depends_on , blocks , moco_confidential )
250- else :
270+ if not is_missing_component_exception (e ):
251271 raise e
272+ self .logger .log ("The component %s :: %s from %s doesn't exist; filing in %s :: %s instead." % (
273+ library .bugzilla_product , library .bugzilla_component , library .yaml_path ,
274+ FALLBACK_PRODUCT_COMPONENT [0 ], FALLBACK_PRODUCT_COMPONENT [1 ]), level = LogLevel .Warning )
275+ bugID = self ._file_bug (FALLBACK_PRODUCT_COMPONENT [0 ], FALLBACK_PRODUCT_COMPONENT [1 ],
276+ summary , description , cc_list , needinfo , see_also , depends_on , blocks , moco_confidential )
277+ self ._file_missing_component_bug (library , bugID )
252278
253279 self .logger .log ("Filed Bug with ID" , bugID , level = LogLevel .Info )
254280 return bugID
255281
282+ def _file_bug (self , product , component , summary , description , cc_list , needinfo , see_also , depends_on , blocks , moco_confidential , mark_affected = True ):
283+ try :
284+ return fileBug (self .config ['url' ], self .config ['apikey' ], self .config ['General' ]['ff-version' ],
285+ product , component , summary , description , cc_list , needinfo , see_also , depends_on , blocks , moco_confidential ,
286+ mark_affected = mark_affected )
287+ except Exception as e :
288+ if is_needinfo_exception (e ):
289+ self .logger .log ("Developer is not accepting needinfos, trying again without..." , level = LogLevel .Info )
290+ return self ._file_bug (product , component , summary , description , cc_list , None , see_also , depends_on , blocks , moco_confidential , mark_affected )
291+ raise e
292+
293+ def _file_missing_component_bug (self , library , filed_bug_id ):
294+ needinfo = [UPDATEBOT_OWNER_BZ ]
295+ if library .maintainer_bz and library .maintainer_bz != UPDATEBOT_OWNER_BZ :
296+ needinfo .append (library .maintainer_bz )
297+ try :
298+ bugID = self ._file_bug (UPDATEBOT_PRODUCT_COMPONENT [0 ], UPDATEBOT_PRODUCT_COMPONENT [1 ],
299+ "Update the Bugzilla component in %s" % library .yaml_path ,
300+ CommentTemplates .MISSING_COMPONENT (library , filed_bug_id ),
301+ [], needinfo , None , None , filed_bug_id , False , mark_affected = False )
302+ self .logger .log ("Filed Bug %s about the missing component, blocking bug %s" % (bugID , filed_bug_id ), level = LogLevel .Info )
303+ except Exception as e :
304+ # The library's bug is already filed; don't lose track of it over this.
305+ self .logger .log ("Could not file a bug about the missing component in %s: %s" % (library .yaml_path , e ), level = LogLevel .Error )
306+
256307 @logEntryExit
257308 def comment_on_bug (self , bug_id , comment , needinfo = None , assignee = None ):
258309 if len (comment ) > 65535 :
0 commit comments