Skip to content

Conversation

@jmgasper
Copy link
Contributor

@jmgasper jmgasper commented Nov 4, 2025

@jmgasper jmgasper merged commit 96e89ac into develop Nov 4, 2025
4 checks passed
console.log('[Dry Run] Would truncate target identity.user_social_login');
} else {
console.log('Truncating target identity.user_social_login before import...');
await targetDb.$executeRaw`TRUNCATE TABLE identity.user_social_login RESTART IDENTITY CASCADE`;
Copy link

Choose a reason for hiding this comment

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

[❗❗ security]
Using $executeRaw for SQL execution can be risky if any part of the query is constructed dynamically, as it may lead to SQL injection vulnerabilities. Ensure that the query is static or properly sanitized.


console.log('user_social_login migration completed');
} finally {
await Promise.allSettled([sourceDb.$disconnect(), targetDb.$disconnect()]);
Copy link

Choose a reason for hiding this comment

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

[⚠️ correctness]
Consider using Promise.all instead of Promise.allSettled if you want to ensure that both database connections are properly closed. Promise.allSettled will not throw an error if one of the promises is rejected, which might mask issues with disconnecting.


const mockMemberPrisma: Partial<MemberPrismaService> = {
const memberUpdateMock = jest.fn();
const mockMemberPrisma: any = {
Copy link

Choose a reason for hiding this comment

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

[⚠️ maintainability]
Using any for mockMemberPrisma can lead to type safety issues. Consider using a more specific type or interface to ensure the mock object aligns with expected structure.

beforeEach(() => {
jest.clearAllMocks();

memberUpdateMock.mockResolvedValue(undefined);
Copy link

Choose a reason for hiding this comment

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

[⚠️ correctness]
The test case should log an error if members.member update fails but continue does not verify the continuation of the process after logging the error. Consider adding assertions to ensure the process continues as expected.

const userIdString = '1';
const oldStatus = 'U';
const newStatus = 'A'; // Unverified to Active
const statusComment = 'Unit test comment';
Copy link

Choose a reason for hiding this comment

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

[💡 design]
The addition of statusComment in the updateStatus method calls should be verified for its intended use. Ensure that the comment is being utilized correctly within the method logic.

if (isNaN(userId)) {
throw new BadRequestException('Invalid user ID format.');
}
const normalizedEmail = newEmail.toLowerCase();
Copy link

Choose a reason for hiding this comment

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

[⚠️ correctness]
Consider validating newEmail before converting it to lowercase to ensure it is a valid email format. This can prevent unnecessary operations if the email is invalid.


if (emailChanged) {
try {
await this.memberPrisma.member.update({
Copy link

Choose a reason for hiding this comment

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

[❗❗ maintainability]
The update operation on members.member should be part of the transaction to ensure consistency. If the transaction fails after updating the email in the email table but before updating members.member, the data could become inconsistent.

if (emailAddress && user?.handle) {
const domain =
this.configService.get<string>('APP_DOMAIN') || 'topcoder-dev.com';
const domain = CommonUtils.getAppDomain(this.configService);
Copy link

Choose a reason for hiding this comment

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

[⚠️ correctness]
Ensure that CommonUtils.getAppDomain(this.configService) returns a valid domain. If the configuration is incorrect, it could lead to malformed email addresses.

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.

2 participants