From 0f0c2b591253c51e6d7629d5993eff6f3aca983c Mon Sep 17 00:00:00 2001 From: Sanjai Kumar <161328623+sanjaikumar-bruno@users.noreply.github.com> Date: Mon, 2 Feb 2026 16:50:06 +0530 Subject: [PATCH] Revert "fix: ephemeral environment variables being saved to filesystem (#6723)" (#7012) This reverts commit 5b1b1b55410f7cdc8959f04055ea9e34db0bc923. --- .../ReduxStore/slices/collections/actions.js | 4 ++-- packages/bruno-app/src/utils/environments.js | 21 +++++++------------ 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js index f3f3cfef0..84884aae3 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js @@ -1909,8 +1909,8 @@ export const saveEnvironment = (variables, environmentUid, collectionUid) => (di Modal Save writes what the user sees: - Non-ephemeral vars are saved as-is (without metadata) - Ephemeral vars: - - if persistedValue exists, save that (restore original value) - - otherwise filter out (don't save script-created ephemeral vars) + - if persistedValue exists, save that (explicit persisted case) + - otherwise save the current UI value (treat as user-authored) */ const persisted = buildPersistedEnvVariables(variables, { mode: 'save' }); environment.variables = persisted; diff --git a/packages/bruno-app/src/utils/environments.js b/packages/bruno-app/src/utils/environments.js index a6836c69a..8ce488aa4 100644 --- a/packages/bruno-app/src/utils/environments.js +++ b/packages/bruno-app/src/utils/environments.js @@ -12,31 +12,24 @@ const toPersistedEnvVarForMerge = (persistedNames) => (v) => { return rest; }; -const isPersistableEnvVarForSave = (v) => { - if (!v) return false; - return !v.ephemeral || v.persistedValue !== undefined; -}; - const toPersistedEnvVarForSave = (v) => { const { ephemeral, persistedValue, ...rest } = v || {}; return v?.ephemeral ? (persistedValue !== undefined ? { ...rest, value: persistedValue } : rest) : rest; }; -// mode 'save': filters out ephemeral vars without persistedValue (script-created, never on disk) -// mode 'merge': same as 'save', but also includes ephemeral vars explicitly persisted this run +/* + High-level builder for persisted variables + - mode 'save': write what the user sees + - mode 'merge': write only allowed vars (non-ephemeral, ephemerals with persistedValue, or explicitly persisted this run) +*/ export const buildPersistedEnvVariables = (variables, { mode, persistedNames } = {}) => { const src = Array.isArray(variables) ? variables : []; if (mode === 'merge') { const names = persistedNames instanceof Set ? persistedNames : new Set(); - return src - .filter(isPersistableEnvVarForMerge(names)) - .map(toPersistedEnvVarForMerge(names)); + return src.filter(isPersistableEnvVarForMerge(names)).map(toPersistedEnvVarForMerge(names)); } - // default to save mode - return src - .filter(isPersistableEnvVarForSave) - .map(toPersistedEnvVarForSave); + return src.map(toPersistedEnvVarForSave); }; export const buildEnvVariable = ({ envVariable: obj, withUuid = false }) => {