Validate preference values set via the CLI (#7346)#10047
Conversation
|
Warning Review limit reached
More reviews will be available in 7 minutes and 15 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 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 |
49b4d77 to
5fb1856
Compare
The CLI set-prefs path (save_pref -> Preferences.save_cli) wrote the raw value to the configuration database without any type validation and always reported success, unlike the GUI path which validates via _Preference.set(). Route save_cli through the same set() validation (set() now accepts an explicit user_id so it works outside a request context), and make setup.py set-prefs check the result and report preferences whose value was invalid. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5fb1856 to
a868adb
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes CLI preference updates (setup.py set-prefs) silently accepting invalid values by routing CLI updates through the same type-validation logic used for preference setting, and by reporting failures to the user.
Changes:
- Extend
_Preference.set()to accept an optionaluser_idso it can be used outside a request context. - Update
Preferences.save_cli()to resolve the preference object and delegate to_Preference.set()for validation. - Update
setup.py set-prefsto detect failed updates and report them; add a 9.16 release note entry.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
web/setup.py |
Checks CLI preference save result and reports failures. |
web/pgadmin/utils/preferences.py |
Enables CLI validation by allowing _Preference.set() to target a specific user and reworking save_cli() to validate via set(). |
docs/en_US/release_notes_9_16.rst |
Adds release note for CLI preference validation fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| :param user_id: User to set the preference for; defaults to the | ||
| current user. | ||
|
|
||
| :returns: nothing. |
| if len(invalid_value_prefs) >= 1: | ||
| print("Invalid value provided for preference(s) " | ||
| "[red]{0}[/red].".format( | ||
| (', ').join(invalid_value_prefs))) |
Summary
Fixes #7346.
Preferences set via the CLI (
setup.py set-prefs) were not validated:Preferences.save_cliwrote the raw value straight to the configuration database and always returned success, so an invalid value (e.g. a non-numeric string for an integer preference) was stored silently. The GUI path validates via_Preference.set().Fix:
_Preference.set()now accepts an optionaluser_id, so it can be used outside a request context (the CLI has nocurrent_user).Preferences.save_clinow looks up the preference (likePreferences.save) and delegates toset(), so the value is validated against the preference type.setup.py set-prefschecks the result and reports any preference whose value was invalid instead of silently claiming success.The GUI path is unaffected (
save_cliis only used by the CLI;update()callspref.set()directly).Changes
web/pgadmin/utils/preferences.py,web/setup.py🤖 Generated with Claude Code