Repository navigation
fix(app): prevent runtime variables from leaking across environments - #8830
Max-Reisinger wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Walkthrough
ChangesEnvironment Runtime Variable Isolation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.ts (1)
47-49: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse a page-module response locator.
page.locator('.response-pane')adds a raw selector to the spec. Expose the response pane throughtests/utils/page/locatorsand consume that helper here.As per coding guidelines and path instructions, specs must centralize locators/actions in
tests/utils/page/*and avoid inline raw selectors.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.ts` around lines 47 - 49, Replace the inline page.locator('.response-pane') usage in the Runtime variables do not leak across collection environments test with the response-pane locator exposed by tests/utils/page/locators, and use that page-module helper through the existing page fixture.Sources: Coding guidelines, Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js`:
- Around line 421-425: Update runtimeVariablesUpdateEvent and its dispatchers to
include the originating environment or scope with each payload, then ignore
updates whose origin no longer matches the collection’s active environment after
selectEnvironment clears runtimeVariables. Preserve valid updates for the
current environment and add a regression test covering an update arriving after
an environment switch.
---
Nitpick comments:
In `@tests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.ts`:
- Around line 47-49: Replace the inline page.locator('.response-pane') usage in
the Runtime variables do not leak across collection environments test with the
response-pane locator exposed by tests/utils/page/locators, and use that
page-module helper through the existing page fixture.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: b4a2bd30-f99b-412b-bfab-8d56bc06b654
📒 Files selected for processing (6)
packages/bruno-app/src/providers/ReduxStore/slices/collections/index.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/index.spec.jstests/interpolation/dynamic-variable/collection/environments/A.brutests/interpolation/dynamic-variable/collection/environments/B.brutests/interpolation/dynamic-variable/collection/read-environment-variable.brutests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.ts
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js (1)
421-425: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy liftReset runtime variables on every environment transition.
selectEnvironmentclearsruntimeVariablesonly for transitions handled by this reducer. The same file assignsactiveEnvironmentUiddirectly inapplyDefaultEnvironmentandcollectionAddEnvFileEvent. Those paths can activate an environment without clearing variables from the previous selection.Move the transition comparison into a shared helper, or apply the same reset at every direct
activeEnvironmentUidassignment. The direct assignments at Lines 442 and 3146 support this finding.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js` around lines 421 - 425, Ensure runtimeVariables is reset whenever activeEnvironmentUid changes, not only in selectEnvironment. Reuse a shared transition helper or add equivalent previous-versus-new environment checks to applyDefaultEnvironment and collectionAddEnvFileEvent, while preserving the existing null normalization and avoiding resets when the environment remains unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js`:
- Around line 421-425: Ensure runtimeVariables is reset whenever
activeEnvironmentUid changes, not only in selectEnvironment. Reuse a shared
transition helper or add equivalent previous-versus-new environment checks to
applyDefaultEnvironment and collectionAddEnvFileEvent, while preserving the
existing null normalization and avoiding resets when the environment remains
unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: cffe13f6-47a8-44dd-b49b-da7ab8d18f0e
📒 Files selected for processing (4)
packages/bruno-app/src/providers/ReduxStore/slices/collections/index.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/index.spec.jspackages/bruno-electron/src/ipc/network/index.jstests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- tests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.ts
- packages/bruno-app/src/providers/ReduxStore/slices/collections/index.spec.js
Description
Clear collection runtime variables when the active collection environment actually changes.
This prevents values created with
bru.setVar()in one environment from overriding variables in another environment.Problem
Fixes #8825.
Runtime variables have the highest variable precedence. A runtime variable created while environment A was active remained in
collection.runtimeVariablesafter switching to environment B, causing it to override B's environment variable with the same name.Fix
selectEnvironmentreducer.collection.runtimeVariablesonly when the selected environment UID actually changes.This implementation treats changing the active collection environment as ending the previous runtime-variable context. The current documentation describes runtime variables as collection-scoped, so this behavior is called out for maintainer confirmation.
Testing
npm test --workspace=packages/bruno-app -- --runInBand src/providers/ReduxStore/slices/collections/index.spec.jsnpx playwright test tests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.ts --project=default --grep "Runtime variables do not leak"npm run lint -- packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js packages/bruno-app/src/providers/ReduxStore/slices/collections/index.spec.js tests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.tsnpm run build:webThe targeted lint command completed with zero errors. It reports pre-existing warnings in the collections reducer outside the changed lines.
Screenshots
Not applicable. The behavior is covered by the Playwright regression test.
Contribution Checklist:
Summary by CodeRabbit
Bug Fixes
Tests