refactor: search alert construction for no resolved repos
Created by: rvantonder
This refactor concentrates logic that creates search alerts and suggestions when repos are not resolved for a search. I was working on this part of the code before, but now it is more immediately important prep-work for #8739. The gist is to create search alerts in-place for each of the cases we currently handle, instead of tracking assignments to search alert title
, description
, etc across some hundred lines and not being able to clearly see when the final value for the alert field is set by the control flow.
Reviewer: please go by commit or this will be tough to read through. The change is semantics-preserving except that previously the alert construction could fail (and return an err
) when it attempts to subsequently resolve reports for query suggestions. I have made it so that it cannot fail, and instead emits the alert, but without the suggestion in case of errors. In principle I don't think alert construction should ever fail--the user shouldn't miss seeing an alert because something errored when trying to make the alert more informative.
In practice and specific to this change: resolveRepositories
is the function that may fail during alert construction, but that same function is called before alert construction, so any error that raises the second time during alert construction is very likely less critical (or can be reasonably suppressed) because any critical related errors would be caught the first time around.