-
Notifications
You must be signed in to change notification settings - Fork 8
fix: add deduplication methods for connection string parameters #478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add deduplication methods for connection string parameters #478
Conversation
…update related tests
…g up orphaned items
…ng-duplicate-parameters
…ng-duplicate-parameters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds deduplication methods for MongoDB connection string query parameters to fix bugs where parameters were doubled during migration or editing operations. The implementation adds new methods to detect and remove duplicate parameters while preserving legitimate multi-value parameters (like readPreferenceTags).
Changes:
- Adds
deduplicateQueryParameters(),hasDuplicateParameters(), and staticnormalize()methods toDocumentDBConnectionStringclass - Implements a cleanup function
cleanupDuplicateConnectionStringParameters()that runs during extension initialization to fix existing corrupted connection strings - Changes the post-migration error resolution flow to await critical fixes (folder placeholder strings and duplicate parameters) before proceeding, with orphan cleanup continuing as fire-and-forget
- Updates v1 to v2 migration to deduplicate connection strings during the migration process
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/documentdb/utils/DocumentDBConnectionString.ts | Adds three new methods for detecting and removing duplicate query parameters from connection strings |
| src/documentdb/utils/DocumentDBConnectionString.test.ts | Comprehensive test coverage for deduplication methods including real-world Cosmos DB connection strings with special characters |
| src/documentdb/utils/connectionStringHelpers.ts | Exports helper functions normalizeConnectionString() and hasDuplicateParameters() for public API |
| src/services/connectionStorageService.ts | Implements cleanup function for duplicate parameters, updates initialization flow to await critical fixes, and adds deduplication to v1 migration |
| src/services/connectionStorageService.test.ts | Adds tests for duplicate parameter removal during v1 to v3 migration and real-world Cosmos DB connection string handling |
| src/services/connectionStorageService.cleanup.test.ts | New test file with comprehensive tests for all cleanup functions including deduplication, folder fixes, and orphan cleanup |
| src/services/connectionStorageService.contract.test.ts | Updates test credentials to use more obviously fake values for security scanning |
| .azure-pipelines/compliance/CredScanSuppressions.json | Adds suppressions for new test files containing fake credentials |
|
@copilot open a new pull request to apply changes based on the comments in this thread |
Co-authored-by: tnaum-ms <171359267+tnaum-ms@users.noreply.github.com>
…ion with whitelist - Created comprehensive documentation (connection-string-parameters.md) explaining which parameters can have multiple values - Identified readPreferenceTags as the only parameter that allows multiple values per MongoDB spec - Updated deduplicateQueryParameters() to follow "last value wins" for non-whitelisted parameters - Added MULTI_VALUE_PARAMETERS whitelist for proper handling - Added tests verifying correct behavior for both whitelisted and non-whitelisted parameters - All tests passing (76/76) Co-authored-by: tnaum-ms <171359267+tnaum-ms@users.noreply.github.com>
Added explanatory comment about case-insensitive matching per MongoDB spec Co-authored-by: tnaum-ms <171359267+tnaum-ms@users.noreply.github.com>
…ng-duplicate-parameters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
This pull request adds robust handling and documentation for duplicate query parameters in DocumentDB and MongoDB connection strings, ensuring compliance with MongoDB specifications and improving reliability when parsing or normalizing connection strings. The core logic now distinguishes between parameters that allow multiple values (like
readPreferenceTags) and those that should only use the last value, and provides utility functions for normalization and duplicate detection.Enhancements to connection string handling:
Added deduplication and normalization logic:
deduplicateQueryParameters,hasDuplicateParameters, and a staticnormalizemethod inDocumentDBConnectionStringto remove duplicate parameters and ensure only allowed duplicates (e.g.,readPreferenceTags) are preserved, following MongoDB spec.normalizeConnectionStringandhasDuplicateParametersinconnectionStringHelpers.tsfor easier use throughout the codebase.Improved testing:
DocumentDBConnectionString.test.tsto verify deduplication, normalization, and duplicate detection logic, including real-world Cosmos DB connection string scenarios and round-trip parsing/serialization.Documentation and compliance:
connection-string-parameters.md) explaining which MongoDB connection string parameters can have multiple values, the rationale for deduplication, and references to official specifications.