BE30: Complete user preferences and settings backend#250
Open
vicheachin1688 wants to merge 1 commit into
Open
Conversation
- Fix partial update data loss bug in updateUserPreferences.js - Add UI settings endpoints (GET/PUT /preferences/extended/ui-settings) - Standardize extended preferences API contract to v3 - Add validateExtendedUserPreferences and validateUiSettings validators - Support canonical nested food_preferences payload - Merge notification_preferences instead of overwriting - Add/update unit and integration test coverage (27 passing)
TienNguyen3711
requested changes
May 8, 2026
Collaborator
TienNguyen3711
left a comment
There was a problem hiding this comment.
Needs a quick follow-up before merge:
food_preferences.allergiesandfood_preferences.health_conditionsare accepted by validation but are not applied inupdateUserPreferences, so the API can return success while silently ignoring those fields.- Nested preference refs should require positive integer
id/referenceId; right now invalid values can pass validation and then get dropped by the model. - The notification preferences response shape changed to
data.notification_preferences; please confirm this contract change is intentional and that existing consumers are updated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR completes the backend implementation for BE30. The primary focus was fixing a critical data loss bug where partial updates to user settings would unintentionally wipe out unrelated preference groups.
Key changes:
Fixed the persistence logic in updateUserPreferences.js. The system now correctly merges updates for health context, food preferences, and notification settings rather than overwriting them. This means changing a UI theme will no longer delete your food allergies.
Added full support for UI settings. We implemented new GET and PUT endpoints for /api/user/preferences/extended/ui-settings to handle theme, language, and font size preferences.
Standardized API responses. All modified endpoints now return a consistent JSON envelope containing success, data, and contractVersion fields.
Strengthened validation. We added comprehensive checks in the validator for nested payloads, specific notification flags, and UI setting values to prevent malformed data from reaching the database.
Verified with 27 automated tests. We updated the unit and integration test suites to specifically cover partial update safety, nested payload persistence, and error handling for invalid inputs.
Endpoints updated or added:
GET and PUT /api/user/preferences/extended
GET and PUT /api/user/preferences/extended/notifications
GET and PUT /api/user/preferences/extended/ui-settings
Total tests passing for BE30 scope: 27 passing, 0 failing.