-
Notifications
You must be signed in to change notification settings - Fork 244
feat(compass-collection): Disable Mock Data Generator button if fields end in "[]" - CLOUDP-347300 #7497
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
Conversation
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 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
processNamedFieldto 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}'` |
Copilot
AI
Oct 23, 2025
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.
Extra space before semicolon. Should be end with '[]'; field name: (no space before semicolon).
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.
^ 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: '[]'" |
Copilot
AI
Oct 23, 2025
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.
Extra space before semicolon. Should be end with '[]'; field name: (no space before semicolon).
|
|
||
| expect(() => processSchema(schema)).to.throw( | ||
| ProcessSchemaUnsupportedStateError, | ||
| "no support for field names that end with '[]' ; field name: 'users[]'" |
Copilot
AI
Oct 23, 2025
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.
Extra space before semicolon. Should be end with '[]'; field name: (no space before semicolon).
|
|
||
| expect(() => processSchema(schema)).to.throw( | ||
| ProcessSchemaUnsupportedStateError, | ||
| "no support for field names that end with '[]' ; field name: 'child[]'" |
Copilot
AI
Oct 23, 2025
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.
Extra space before semicolon. Should be end with '[]'; field name: (no space before semicolon).
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.

Checklist
Types of changes