Add validation to prevent blank deployment parameters

What does this MR do and why?

Add allow_blank: false validation to required deployment API parameters (environment, sha, ref) to ensure they contain non-empty values. Previously, the API only validated parameter presence, allowing empty strings or whitespace-only values to pass through.

This change also adds explicit SHA validation to check if the commit exists in the repository before attempting to create the deployment, preventing StatusUpdateError exceptions when invalid SHAs are provided.

The validation now catches these errors at the API layer with a 400 response instead of failing later during deployment status transitions with "Sha can't be blank" or "The commit does not exist" errors.

Parameters can be defined as allow_blank, ensuring that they contain a value. By default, requires only validates that a parameter was sent in the request, regardless its value. With allow_blank: false, empty values or whitespace only values are invalid.

The above is from the Grape readme https://github.com/ruby-grape/grape?tab=readme-ov-file#allow_blank on why we need the allow_blank: false option.

References

Sentry link

How to set up and validate locally

Invoke the create deployment API with an empty sha sha='' or run the specs.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #579623

Merge request reports

Loading