Skip to content

Conversation

@sanjaikumar-bruno
Copy link
Member

@sanjaikumar-bruno sanjaikumar-bruno commented Dec 29, 2025

BRU-2405

savePreferences() validated partial updates without merging existing preferences, causing failures when required fields (e.g., proxy.inherit) were missing. Updated savePreferences() to merge incoming preferences with existing preferences before validation, allowing partial updates while keeping the schema strict.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 29, 2025

Walkthrough

The savePreferences function in the preferences store now merges new preferences with existing ones before validation, ensuring complete validation of the merged object rather than partial input.

Changes

Cohort / File(s) Summary
Preferences Validation Logic
packages/bruno-electron/src/store/preferences.js
Modified savePreferences to merge incoming preferences with existing ones before validation, enabling safe partial updates while maintaining data integrity through full-object validation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🎭 Preferences merge with grace,
New values find their rightful place,
Validation checks the whole, not part,
Ensuring data stays smart! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: merging preferences before validation to resolve validation errors during workspace documentation saves.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 018f392 and b5cf2b5.

📒 Files selected for processing (1)
  • packages/bruno-electron/src/store/preferences.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-electron/src/store/preferences.js
🧠 Learnings (1)
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.

Applied to files:

  • packages/bruno-electron/src/store/preferences.js
🧬 Code graph analysis (1)
packages/bruno-electron/src/store/preferences.js (1)
packages/bruno-app/src/components/Preferences/General/index.js (1)
  • preferencesSchema (19-64)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: Unit Tests
  • GitHub Check: CLI Tests
🔇 Additional comments (1)
packages/bruno-electron/src/store/preferences.js (1)

232-241: Excellent fix for partial updates!

The merge-before-validate approach correctly solves the validation issue when partial preferences are saved. The implementation is clean, well-commented, and ensures all required schema fields are present during validation.

One thing to be aware of: lodash.merge performs a deep merge, meaning nested objects are merged recursively rather than replaced entirely. For example, updating proxy.inherit alone will preserve the existing proxy.config object. This is the right behavior for partial updates, but if a future use case requires replacing an entire nested object (not merging), you'd need a different approach.

Given the typical usage pattern (get full preferences → modify specific fields → save), this deep merge is appropriate.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant