Skip to content

Conversation

kmruiz
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 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
@coveralls
Copy link
Collaborator

coveralls commented Sep 5, 2025

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants