Skip to content

Check deploy_key exists during ProtectedRefDeployKeyAccess#valid?

Joe Woodward requested to merge fix/461213-branch_rule-validations into master

What does this MR do and why?

Check deploy_key exists during ProtectedRefDeployKeyAccess#valid?

Prior to this change we did not validate that the deploy_key actually existed when creating a ProtectedRefDeployKeyAccess object.

We have foreign_key constraints but this means we relied on the database layer to raise exceptions instead of returning user friendly errors.

This change also modifies how we check if a ProtectedRefDeployKeyAccess is a deploy_key record. Previously we would check if deploy_key existed for ProtectedRefDeployKeyAccess#type => :deploy_key. This meant that passing an invalid deploy_key_id would result in ProtectedRefDeployKeyAccess#type => :role when it should be considered a deploy_key type access level.

Related to #461213

Changelog: changed

MR acceptance checklist

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

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Merge request reports