Skip to content

Conversation

@kylelai1
Copy link
Collaborator

@kylelai1 kylelai1 commented Oct 17, 2025

Description

  • Adds the connection string to the script screen of the mock data generator modal

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)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

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)
Screenshot 2025-10-16 at 8 36 27 PM

@github-actions github-actions bot added the feat label Oct 17, 2025
@kylelai1 kylelai1 marked this pull request as ready for review October 17, 2025 15:36
@kylelai1 kylelai1 requested a review from a team as a code owner October 17, 2025 15:36
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

Adds a user-friendly Atlas connection string to metadata and surfaces it in the mock data generator script screen.

  • Introduces atlasMetadata.userConnectionString and a fallback constant.
  • Updates script generation to interpolate the connection string.
  • Adds tests for both provided and fallback connection string display.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/connection-info/src/connection-info.ts Adds userConnectionString field with doc comment.
packages/compass-generative-ai/src/atlas-ai-service.spec.ts Updates mock ConnectionInfo to include new field.
packages/compass-collection/src/stores/collection-tab.spec.ts Adds userConnectionString to mock atlas connection info.
packages/compass-collection/src/components/mock-data-generator-modal/script-screen.tsx Makes mongosh command dynamic based on connection string with fallback.
packages/compass-collection/src/components/mock-data-generator-modal/mock-data-generator-modal.spec.tsx Adds tests for userConnectionString and fallback behavior.
packages/compass-collection/src/components/mock-data-generator-modal/constants.ts Defines DEFAULT_CONNECTION_STRING_FALLBACK constant.
packages/compass-collection/src/components/collection-header/collection-header.spec.tsx Adds userConnectionString to mock metadata.
packages/compass-collection/src/components/collection-header-actions/collection-header-actions.spec.tsx Adds userConnectionString to mock metadata.

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

Comment on lines +111 to +112
* User-friendly connection string for the Atlas cluster, which uses the SRV address if available.
* Otherwise, will default to <your-cluster> as a placeholder.
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

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

The doc comment says the fallback defaults to , but the actual fallback used elsewhere is the full SRV form mongodb+srv://.mongodb.net/. Update the comment to reflect the exact expected format and clarify whether userConnectionString should always be a full connection string (including protocol and optional database) or just a host placeholder.

Suggested change
* User-friendly connection string for the Atlas cluster, which uses the SRV address if available.
* Otherwise, will default to <your-cluster> as a placeholder.
* User-friendly connection string for the Atlas cluster, typically in the SRV format:
* mongodb+srv://<your-cluster>.mongodb.net/<your-database>
* If the SRV address is not available, the fallback is the full SRV form with placeholders:
* mongodb+srv://<your-cluster>.mongodb.net/<your-database>
* This property should always be a full connection string, including protocol and optional database.

Copilot uses AI. Check for mistakes.
@kylelai1 kylelai1 requested review from leo-generali and removed request for leo-generali October 17, 2025 15:37
const RUN_SCRIPT_COMMAND = `
mongosh "mongodb+srv://<your-cluster>.mongodb.net/<your-database>" \\
const RUN_SCRIPT_COMMAND = (connectionString: string) => `
mongosh "${connectionString}" \\
Copy link
Contributor

Choose a reason for hiding this comment

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

And this is definitely not going to already contain username/password or even placeholders for username/password?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct, only the SRV address connection string here, without the username/password.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's fine, but just in case you want some extra certainty for-almost-free, you can use

Suggested change
mongosh "${connectionString}" \\
mongosh "${redactConnectionString(connectionString)}" \\

with

import { redactConnectionString } from 'mongodb-connection-string-url';

That's a dependency we already freely use within Compass so it's basically an extra zero-cost safeguard

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah yeah, good idea. Let me add this in.

};

export const DEFAULT_CONNECTION_STRING_FALLBACK =
'mongodb+srv://<your-cluster>.mongodb.net/<your-database>';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just want to confirm that this fallback with the <your-database> at the end is proper

Copy link
Collaborator Author

@kylelai1 kylelai1 Oct 17, 2025

Choose a reason for hiding this comment

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

Technically <your-cluster> alone as well isn't the best representation here of the connection string, since it'll be the SRV address, so something like Cluster0.AHFBW.mongodb.net for example. I took the existing placeholder and just refactored that here.

If we want something more accurate, we could just remove the placeholder and instead could just do '<srv-connection-string>' and have the user grab the connection string on their own.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good to me!

connectionInfo: atlasConnectionInfo,
fakerSchemaGeneration: {
status: 'completed',
fakerSchema: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Merge conflict fix:

Suggested change
fakerSchema: {
originalLlmResponse: {
name: {
fakerMethod: 'person.firstName',
fakerArgs: [],
probability: 1.0,
mongoType: 'String',
},
},
editedFakerSchema: {

connectionInfo: atlasConnectionInfoWithoutAtlasMetadata,
fakerSchemaGeneration: {
status: 'completed',
fakerSchema: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

And here

Suggested change
fakerSchema: {
originalLlmResponse: {
name: {
fakerMethod: 'person.firstName',
fakerArgs: [],
probability: 1.0,
mongoType: 'String',
},
},
editedFakerSchema: {

@jcobis jcobis added the no release notes Fix or feature not for release notes label Oct 23, 2025
@kylelai1 kylelai1 merged commit 2051b4b into main Oct 23, 2025
76 of 80 checks passed
@kylelai1 kylelai1 deleted the CLOUDP-347558 branch October 23, 2025 15:55
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.

6 participants