-
Notifications
You must be signed in to change notification settings - Fork 12
Add headers support for MongoDB Atlas API v2 compatibility #60
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
base: master
Are you sure you want to change the base?
Conversation
|
@montumodi 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
Co-authored-by: montumodi <12596663+montumodi@users.noreply.github.com>
| const requestParams = {"digestAuth": "dummyPublicKey:dummyPrivateKey", "dataType": "json"}; | ||
| const requestParams = {"digestAuth": "dummyPublicKey:dummyPrivateKey", "dataType": "json", "headers": {}}; | ||
| await atlasSearch.get("clusterName", "indexId", {"queryStringParam1": "value1", "httpOptions": {"options1": "value1"}}); | ||
| expect(mockRequest.request.calledWith("dummyBaseUrl/groups/dummyProjectId/clusters/clusterName/fts/indexes/indexId?queryStringParam1=value1", {...requestParams, "options1": "value1"})).to.be.true(); |
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.
@copilot shouldn't there be a check that headers are being passed correctly?
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.
You're absolutely right! I've added tests to verify that headers are being passed correctly when using AtlasSearch methods:
- Integration test: Verifies that custom headers configured on the client are included in actual HTTP requests made by AtlasSearch methods
- Unit test: Verifies that custom headers are properly passed to the underlying request mechanism
The tests ensure that when a client is configured with custom headers (like "Accept": "application/vnd.atlas.2025-03-12+json"), those headers are correctly propagated through AtlasSearch method calls.
Commit: 1105829
Co-authored-by: montumodi <12596663+montumodi@users.noreply.github.com>
This PR adds support for custom headers in the MongoDB Atlas API client to enable compatibility with the new MongoDB Atlas Administration API v2.
Progress Checklist
Recent Changes
Added specific tests to verify that custom headers are properly passed through when using AtlasSearch methods:
Implementation Details
fetch/fetchStreammethods to properly merge default headers with method-specific headersgetMongodbAtlasApiClientto pass headers from configuration to HttpClientheaders?: Record<string, string>toAtlasClientConfiginterfaceContent-Type) andhttpOptionsheaders, with method-specific headers taking precedenceTesting
Added comprehensive test suite covering:
All tests pass with 100% code coverage maintained.
Fixes #58.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.