Skip to content

Fixed an issue where modifying a shared server incorrectly updated the original server details. #9258#9668

Merged
khushboovashi merged 2 commits intopgadmin-org:masterfrom
pravesh-sharma:GH-9258
Feb 25, 2026
Merged

Fixed an issue where modifying a shared server incorrectly updated the original server details. #9258#9668
khushboovashi merged 2 commits intopgadmin-org:masterfrom
pravesh-sharma:GH-9258

Conversation

@pravesh-sharma
Copy link
Contributor

@pravesh-sharma pravesh-sharma commented Feb 24, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of connections to shared servers to prevent stale state or session-related conflicts when switching between servers, ensuring the correct server properties are used.
    • Makes shared-server switching more reliable without changing visible workflows or error behavior.

@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ea4323 and a164f8b.

📒 Files selected for processing (1)
  • web/pgadmin/browser/server_groups/servers/__init__.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/pgadmin/browser/server_groups/servers/init.py

Walkthrough

Replaces a direct db.session.expunge(server) with obtaining the server's SQLAlchemy session via object_session(server) and calling session.expunge(server) if that session exists, before merging shared server properties during connect for shared servers.

Changes

Cohort / File(s) Summary
SQLAlchemy session detachment
web/pgadmin/browser/server_groups/servers/__init__.py
Added from sqlalchemy.orm import object_session; when connecting to a shared server (server.shared and server.user_id != current_user.id) obtain the server's SQLAlchemy session via object_session(server) and call session.expunge(server) if present, then continue replacing server object with shared properties.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 3
✅ 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 clearly and specifically describes the main bug fix: preventing shared server modifications from incorrectly updating the original server, and references the related issue number.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/pgadmin/browser/server_groups/servers/__init__.py`:
- Around line 1468-1473: The code unconditionally calls
db.session.expunge(server) which can raise or be a no-op for detached instances;
update the block in the connect flow to check
sqlalchemy.orm.session.object_session(server) (or db.session.object_session) and
only call db.session.expunge(server) when that returns a truthy session; keep
the surrounding logic that loads shared_server via
ServerModule.get_shared_server and ServerModule.get_shared_server_properties
as-is, but guard the expunge call using object_session(server) to safely handle
both attached and detached Server instances.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6d0d387 and 3ea4323.

📒 Files selected for processing (1)
  • web/pgadmin/browser/server_groups/servers/__init__.py

@khushboovashi khushboovashi merged commit 5dd63ca into pgadmin-org:master Feb 25, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants