diff --git a/changelog/11143.txt b/changelog/11143.txt new file mode 100644 index 000000000..e847eb908 --- /dev/null +++ b/changelog/11143.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Fix error message caused by control group +``` diff --git a/ui/app/components/secret-edit.js b/ui/app/components/secret-edit.js index 49eb853f6..8ed124a7e 100644 --- a/ui/app/components/secret-edit.js +++ b/ui/app/components/secret-edit.js @@ -9,6 +9,7 @@ import WithNavToNearestAncestor from 'vault/mixins/with-nav-to-nearest-ancestor' import keys from 'vault/lib/keycodes'; import KVObject from 'vault/lib/kv-object'; import { maybeQueryRecord } from 'vault/macros/maybe-query-record'; +import ControlGroupError from 'vault/lib/control-group-error'; const LIST_ROUTE = 'vault.cluster.secrets.backend.list'; const LIST_ROOT_ROUTE = 'vault.cluster.secrets.backend.list-root'; @@ -16,6 +17,7 @@ const SHOW_ROUTE = 'vault.cluster.secrets.backend.show'; export default Component.extend(FocusOnInsertMixin, WithNavToNearestAncestor, { wizard: service(), + controlGroup: service(), router: service(), store: service(), flashMessages: service(), @@ -197,26 +199,35 @@ export default Component.extend(FocusOnInsertMixin, WithNavToNearestAncestor, { secretData.set(secretData.pathAttr, key); } - return secretData.save().then(() => { - if (!secretData.isError) { - if (isV2) { - secret.set('id', key); + return secretData + .save() + .then(() => { + if (!secretData.isError) { + if (isV2) { + secret.set('id', key); + } + if (isV2 && Object.keys(secret.changedAttributes()).length) { + // save secret metadata + secret + .save() + .then(() => { + this.saveComplete(successCallback, key); + }) + .catch(e => { + this.set(e, e.errors.join(' ')); + }); + } else { + this.saveComplete(successCallback, key); + } } - if (isV2 && Object.keys(secret.changedAttributes()).length) { - // save secret metadata - secret - .save() - .then(() => { - this.saveComplete(successCallback, key); - }) - .catch(e => { - this.set(e, e.errors.join(' ')); - }); - } else { - this.saveComplete(successCallback, key); + }) + .catch(error => { + if (error instanceof ControlGroupError) { + let errorMessage = this.controlGroup.logFromError(error); + this.set('error', errorMessage.content); } - } - }); + throw error; + }); }, saveComplete(callback, key) { if (this.wizard.featureState === 'secret') {