Skip to content

Commit 28d477b

Browse files
committed
Address feedback
1 parent 8815b20 commit 28d477b

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

packages/compass-generative-ai/src/atlas-ai-service.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -467,20 +467,14 @@ export class AtlasAiService {
467467
);
468468
}
469469

470-
/**
471-
* @returns {MockDataSchemaResponse} which contains faker.js mappings used to produce a
472-
* faker.js factory function for the purposes of generating mock document data.
473-
*
474-
* @throws {AtlasAiServiceApiResponseParseError} when the response cannot be parsed into the expected schema.
475-
*/
476470
async getMockDataSchema(
477471
input: MockDataSchemaRequest,
478472
connectionInfo: ConnectionInfo
479473
): Promise<MockDataSchemaResponse> {
480474
const { collectionName, databaseName } = input;
481475
let schema = input.schema;
482476

483-
const url = `${this.getUrlForEndpoint('mock-data-schema', connectionInfo)}`;
477+
const url = this.getUrlForEndpoint('mock-data-schema', connectionInfo);
484478

485479
if (!input.includeSampleValues) {
486480
const newSchema: Record<
@@ -510,14 +504,17 @@ export class AtlasAiService {
510504
const data = await res.json();
511505
return MockDataSchemaResponseShape.parse(data);
512506
} catch {
507+
const errorMessage = 'Response does not match expected schema';
513508
this.logger.log.error(
514509
mongoLogId(1_001_000_311),
515510
'AtlasAiService',
516-
'Failed to parse mock data schema response with expected schema'
517-
);
518-
throw new AtlasAiServiceApiResponseParseError(
519-
'Response does not match expected schema'
511+
'Failed to parse mock data schema response with expected schema',
512+
{
513+
namespace: `${databaseName}.${collectionName}`,
514+
message: errorMessage,
515+
}
520516
);
517+
throw new AtlasAiServiceApiResponseParseError(errorMessage);
521518
}
522519
}
523520

0 commit comments

Comments
 (0)