Fix error when secret.length attribute was undefined.
What does this MR do and why?
When creating a secret, if the name has been populated, the Branches selector does not preserve the value. The JavaScript console produces the following error:
Vue warn]: Error in render: "TypeError: Cannot read properties of undefined (reading 'length')"
found in
---> <SecretForm> at /Users/kmcdonald/Projects/gitlab-development-kit/gitlab/ee/app/assets/javascripts/ci/secrets/components/secret_form/secret_form.vue
<SecretFormWrapper> at /Users/kmcdonald/Projects/gitlab-development-kit/gitlab/ee/app/assets/javascripts/ci/secrets/components/secret_form/secret_form_wrapper.vue
<SecretsApp> at /Users/kmcdonald/Projects/gitlab-development-kit/gitlab/ee/app/assets/javascripts/ci/secrets/components/secrets_app.vue
<Root>
...
secret_form.vue:198 TypeError: Cannot read properties of undefined (reading 'length')
at VueComponent.isValueValid (secret_form.vue:111:1)
at Watcher2.get (vue.runtime.esm.js:3462:33)
at Watcher2.evaluate (vue.runtime.esm.js:3563:27)
at VueComponent.computedGetter [as isValueValid] (vue.runtime.esm.js:5557:25)
at VueComponent.canSubmit (secret_form.vue:85:1)
at Watcher2.get (vue.runtime.esm.js:3462:33)
at Watcher2.evaluate (vue.runtime.esm.js:3563:27)
at VueComponent.computedGetter [as canSubmit] (vue.runtime.esm.js:5557:25)
at Object.get (vue.runtime.esm.js:5349:20)
at Proxy.render (secret_form.vue:240:1)
After investigation, the length attribute was undefined when being referenced. This change is a fix to consider the case when it is no defined.
References
Fixes #574817 (closed)
Screenshots or screen recordings
| Before | After |
|---|---|
|
Selecting while secret name is populated: Selection not preserved: |
Selecting while secret name is populated: Selection is preserved: |
How to set up and validate locally
Using GDK, navigate to the 'Secure->Secrets manager' and click New secret enter a name for the secret and select a branch, the branch form element should be preserved.
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.



