Skip to content

fix(mongodb): SRV ReadPreference decoupling & config robustness#950

Open
siiddhantt wants to merge 2 commits into
datazip-inc:stagingfrom
siiddhantt:fix/mongo-read-preference-srv
Open

fix(mongodb): SRV ReadPreference decoupling & config robustness#950
siiddhantt wants to merge 2 commits into
datazip-inc:stagingfrom
siiddhantt:fix/mongo-read-preference-srv

Conversation

@siiddhantt
Copy link
Copy Markdown
Contributor

@siiddhantt siiddhantt commented May 13, 2026

Description

Fixes #682 - MongoDB SRV ReadPreference bug

This PR decouples the read_preference logic from the replica_set field in the MongoDB driver config. Previously, read_preference was only set if replica_set was non-empty, which broke SRV/Atlas connections and caused silent misconfigurations. Now, read_preference is always respected if provided, regardless of replica_set or srv mode. Also fixes hyphenated JSON keys in docs/tests, and clarifies SRV/replica set usage in documentation.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Unit tests: Added table-driven tests for all URI scenarios in config_test.go
  • Integration: Ran end-to-end proof script with real MongoDB replica set and SRV cluster, verified all edge/breaking cases
  • Manual: Confirmed correct URI construction and sync for both SRV and replica set configs

Screenshots or Recordings

image
  • See attached proof video and script output

Documentation

  • N/A (bug fix, refactor, or test changes only)

Related PR's (If Any):

  • N/A

Checklist:

  • Minimal, focused diff (no unrelated changes)
  • All edge/breaking cases verified
  • Automated proof attached
  • Reviewer feedback from past PRs incorporated

@siiddhantt siiddhantt requested a deployment to integration_tests May 13, 2026 08:57 — with GitHub Actions Waiting
@siiddhantt siiddhantt changed the base branch from master to staging May 13, 2026 08:58
@siiddhantt siiddhantt requested a deployment to integration_tests May 16, 2026 08:08 — with GitHub Actions Waiting
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.

enhancement: Decouple Read Preference from Replica Set configuration for SRV support

1 participant