Fix issue with Username being required for Shared server import config#9971
Fix issue with Username being required for Shared server import config#9971KijongHan wants to merge 4 commits into
Conversation
validate_json_data required Username for all non-Service connections, rejecting legitimate JSON that only carried SharedUsername. Accept either attribute when Shared is true; keep Username required for non-shared servers. Extract is_shared as a local while we're here — it's now referenced twice in the loop body. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…d servers When loading database servers from an import file, fall back to SharedUsername for the underlying server.username when the server is shared and no explicit Username is provided. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughValidation and loader functions in web/pgadmin/utils/init.py now derive an is_shared flag from input and compute an effective username (using SharedUsername when appropriate). Validation enforces username requirements conditionally for shared vs non-shared servers; the loader applies computed shared and username values to the server objects. ChangesShared Server Configuration and Validation
🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsStopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a 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.
Pull request overview
This PR updates pgAdmin’s servers.json import path to correctly handle shared servers by loosening validation so shared server definitions can provide SharedUsername instead of always requiring Username, and by applying a fallback so imported shared servers have an effective username consistent with the UI flow.
Changes:
- Adjusted
servers.jsonvalidation to accept eitherUsernameorSharedUsernamefor shared servers. - Updated server import to populate
Server.usernamefromSharedUsernamewhenUsernameis not provided for shared servers. - Minor refactor to reuse computed
is_sharedduring validation/import.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks for the careful analysis @KijongHan, and for not just rolling over to Copilot — your read on One ask before this lands: please change the fallback at line 739 from if is_shared and not username:
username = shared_usernameto if is_shared and username is None:
username = shared_usernameReason: @hiteshjambhale's reproducer ( The broader question — should On the |
|
thanks so much for your reviews @asheshv @hiteshjambhale and appreciate the followup to some of the questions I've posed. Have addressed your suggested changes. |
|
hi @hiteshjambhale @asheshv Checking to see if you had a chance to rereview my changes that addresses your PR feedback/concerns? Keen to get these changes in! |
Resolves #9226
What does this PR do?
This PR resolves
Username attribute not found for server 'shared_server'errors where server json import validation logic had a hard constraint onUsernamebeing required even whenSharedwas set to true. This PR introduces more coherent constraint validation logic for shared servers so that you are required to either provideSharedUsernameorUsername(for backwards compatibility). Furthermore, the underlying data model 'Username' property is set to 'SharedUsername' (for shared servers only) to align with UI behaviour for setting this fallback.The UX also feels better as when after registering shared servers with only the
SharedUsernameset, when trying to connect to the server for the first time it prompts for the password (instead of showing an infinite loading spinner because the underlyingUsernameis not set)Summary of changes
add separate
Usernameconstraint validation logic for shared servers when importingservers.jsonadd fallback to set
UsernametoSharedUsernamefor shared servers so that the UX flow matches the manual UI creation flow for registering new shared serversSummary by CodeRabbit