Skip to content

Consider raising an error in Deployments::UpdateService when using an unsupported status

The following discussion from !18755 (merged) should be addressed:

  • @ayufan started a discussion: (+1 comment)

    Should we raise an exception here? I'm worried that we miss some status once it is added, and we do not validate that all are covered.

    Other approach is to validate that as part of some kind of enum that all states are covered by this case.

And my comment:

@ayufan Right now the API would never reach this, because it already limits what status values you can use. If it does, the API would return an error status because of this check:

if service.execute
  present(deployment, with: Entities::Deployment, current_user: current_user)
else
  render_validation_error!(deployment)
end

For cases where we use this service class directly one can check the return value. If we are really concerned with this, I suggest taking care of this in a follow-up issue. This isn't important right now, and I doubt we'd introduce a new status any time soon 😃

We should consider changing the service class to raise an error instead of just returning false.