From 45e2bfcad7b02f8f518a6cccf4042f84ca69e94e Mon Sep 17 00:00:00 2001 From: Arnav Palnitkar Date: Tue, 20 Apr 2021 12:11:21 -0700 Subject: [PATCH] Fixed duplicate path issue for kv engine (#11423) - Ids used to collide in ember data while creating a secret with any existing path name from a different kv engine --- ui/app/components/secret-edit.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ui/app/components/secret-edit.js b/ui/app/components/secret-edit.js index 8ed124a7e..4adbc148b 100644 --- a/ui/app/components/secret-edit.js +++ b/ui/app/components/secret-edit.js @@ -199,6 +199,13 @@ export default Component.extend(FocusOnInsertMixin, WithNavToNearestAncestor, { secretData.set(secretData.pathAttr, key); } + if (this.mode === 'create') { + key = JSON.stringify({ + backend: secret.backend, + id: key, + }); + } + return secretData .save() .then(() => { @@ -323,8 +330,14 @@ export default Component.extend(FocusOnInsertMixin, WithNavToNearestAncestor, { return; } - this.persistKey(() => { - this.transitionToRoute(SHOW_ROUTE, this.model.path || this.model.id); + this.persistKey(key => { + let secretKey; + try { + secretKey = JSON.parse(key).id; + } catch (error) { + secretKey = key; + } + this.transitionToRoute(SHOW_ROUTE, secretKey); }); },