Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(readOnly): Do not allow $out and $merge in readOnly mode #525

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

Merged
kmruiz merged 2 commits into main from fix/aggr-readonly-mode
Sep 5, 2025

Conversation

Copy link
Collaborator

@kmruiz kmruiz commented Sep 5, 2025

Proposed changes

MongoDB pipelines can generate new data and store it in another database, collection, S3 bucket and more using both the $merge and $out stages. We are disabling these stages in readOnly mode to avoid unexpected behaviour for the user.

Checklist

@Copilot Copilot AI review requested due to automatic review settings September 5, 2025 13:33
@kmruiz kmruiz requested a review from a team as a code owner September 5, 2025 13:33
@kmruiz kmruiz self-assigned this Sep 5, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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 prevents MongoDB aggregation pipelines from using $out and $merge stages when the system is in read-only mode, ensuring data integrity by blocking operations that could write or modify data outside the current database.

  • Adds validation to reject $out and $merge stages in read-only mode
  • Introduces a new error code for forbidden write operations
  • Includes comprehensive test coverage for both restricted stages

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/tools/mongodb/read/aggregate.ts Adds stage validation logic to prevent write operations in read-only mode
src/common/errors.ts Introduces new error code for forbidden write operations
tests/integration/tools/mongodb/read/aggregate.test.ts Adds test cases to verify $out and $merge stages are blocked in read-only mode

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Collaborator

@himanshusinghs himanshusinghs left a comment

Choose a reason for hiding this comment

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

🚀 Looks good

kmruiz reacted with rocket emoji
@kmruiz kmruiz enabled auto-merge (squash) September 5, 2025 13:40
@kmruiz kmruiz merged commit 14176ba into main Sep 5, 2025
16 checks passed
@kmruiz kmruiz deleted the fix/aggr-readonly-mode branch September 5, 2025 13:41
Copy link
Collaborator

coveralls commented Sep 5, 2025
edited
Loading

Pull Request Test Coverage Report for Build 17494762061

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 16 of 16 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.06%) to 81.415%

Totals Coverage Status
Change from base Build 17487617251: 0.06%
Covered Lines: 4740
Relevant Lines: 5734

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

Copilot code review Copilot Copilot left review comments

@himanshusinghs himanshusinghs himanshusinghs approved these changes

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /