Skip to content

Conversation

@jcobis
Copy link
Collaborator

@jcobis jcobis commented Oct 23, 2025

Description

MongoDB allows field names to contain "[" and "]" characters, but the Mock Data Generator's field path parsing algorithm would misinterpret the edge case where a field ends in a trailing "[]".

Added validation to detect and reject field names ending with "[]" during schema analysis.

Updated the tooltip to display the error message.
Screenshot 2025-10-23 at 1 51 37 PM

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@github-actions github-actions bot added the feat label Oct 23, 2025
@jcobis jcobis marked this pull request as ready for review October 23, 2025 16:18
@jcobis jcobis requested a review from a team as a code owner October 23, 2025 16:18
@jcobis jcobis requested review from Copilot and lerouxb October 23, 2025 16:18
@jcobis jcobis added the no release notes Fix or feature not for release notes label Oct 23, 2025
Copy link
Contributor

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 addresses an edge case in the Mock Data Generator where field names ending with "[]" would be misinterpreted by the field path parsing algorithm. The fix adds validation to reject such field names during schema analysis and updates the error tooltip to display the actual error message instead of a hardcoded message.

Key Changes

  • Added validation in processNamedField to detect and reject field names ending with "[]"
  • Updated error tooltip to display dynamic error messages from schemaAnalysisError
  • Added comprehensive test coverage for the new validation including nested fields and existing dot-containing field names

Reviewed Changes

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

File Description
packages/compass-collection/src/transform-schema-to-field-info.ts Added validation check for field names ending with "[]"
packages/compass-collection/src/transform-schema-to-field-info.spec.ts Added test cases for the new validation rule and updated existing test expectations
packages/compass-collection/src/components/collection-header-actions/collection-header-actions.tsx Updated tooltip to display dynamic error message instead of hardcoded text

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


if (field.name.endsWith('[]')) {
throw new ProcessSchemaUnsupportedStateError(
`no support for field names that end with '[]' ; field name: '${field.name}'`
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

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

Extra space before semicolon. Should be end with '[]'; field name: (no space before semicolon).

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

^ I would address these

expect(() => processSchema(schema)).to.throw(
"invalid fieldPath '[]': field parts must have characters other than '[]'"
ProcessSchemaUnsupportedStateError,
"no support for field names that end with '[]' ; field name: '[]'"
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

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

Extra space before semicolon. Should be end with '[]'; field name: (no space before semicolon).

Copilot uses AI. Check for mistakes.

expect(() => processSchema(schema)).to.throw(
ProcessSchemaUnsupportedStateError,
"no support for field names that end with '[]' ; field name: 'users[]'"
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

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

Extra space before semicolon. Should be end with '[]'; field name: (no space before semicolon).

Copilot uses AI. Check for mistakes.

expect(() => processSchema(schema)).to.throw(
ProcessSchemaUnsupportedStateError,
"no support for field names that end with '[]' ; field name: 'child[]'"
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

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

Extra space before semicolon. Should be end with '[]'; field name: (no space before semicolon).

Copilot uses AI. Check for mistakes.
@jcobis jcobis merged commit a3c4dc7 into main Oct 27, 2025
58 of 60 checks passed
@jcobis jcobis deleted the CLOUDP-347300 branch October 27, 2025 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat no release notes Fix or feature not for release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants