Raise an error when a HostingServiceAccount fails to load a hosting service.

Review Request #12667 — Created Oct. 4, 2022 and submitted — Latest diff uploaded


Review Board


Repositories use their associated HostingServiceAccount to fetch hosting
services. The hosting service account will return None if a hosting service
fails to load. This isn't the greatest thing to do since this hides the fact
that the service didn't load, and instead makes the repository behave as if
they do not have a hosting service configured.

This change instead raises an error when a HostingServiceAccount fails to
load a service. This way, a more appropriate and helpful eror message is shown
when, for example, trying to post changes or view diffs linked to repositories
that use a hosting service that can't be loaded.

This also adds some help texts to the HostingServiceAccount's fields. This
was primarily done to clarify that the service_name field should be set to
the hosting service ID rather than the hosting service name. This assumption
is made everywhere in the code except for in one test file which sets the
field to a hosting service name, which we correct in this change.

  • Ran all unit tests.
  • Tested viewing review requests and diffs that are from a repository that uses
    a hosting service that can't be loaded, saw the HostingServiceError page
  • Tested rbt post REVISION with a git revision, saw a
    500: Internal Server Error response and saw the HostingServiceError get
    raised in the server logs.