Skip to content

Conversation

@jmgasper
Copy link
Contributor

@jmgasper jmgasper commented Nov 4, 2025

@jmgasper jmgasper merged commit dceac79 into master Nov 4, 2025
6 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 not handled properly, as it may lead to SQL injection vulnerabilities. Ensure that the input is sanitized and that this operation is safe in the context it is used.


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 and handle any errors that might occur during disconnection. Promise.allSettled will suppress errors, which might not be desirable in this context.


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 defining a more specific type to ensure that only the necessary properties are mocked and to catch potential errors at compile time.

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]
Resetting the mock implementation of memberUpdateMock to resolve undefined in every beforeEach might hide potential issues if the mock is expected to return a specific value. Ensure that the mock's behavior aligns with the test's expectations.

{ userId: 1, handle: 'testuser' },
);
expect(result).toEqual(mockUser);
expect(memberUpdateMock).toHaveBeenCalledWith({
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 checks if memberUpdateMock is called with a specific object. Ensure that the userId variable is defined and correctly scoped within the test to avoid potential reference errors.

);
});

it('should log an error if members.member update fails but continue', async () => {
Copy link

Choose a reason for hiding this comment

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

[⚠️ design]
The test logs an error if members.member update fails but continues execution. Consider whether this behavior is appropriate, as it might lead to inconsistent states if the update is critical. Evaluate if the test should assert on the final state or outcome.

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.

[❗❗ correctness]
The updateStatus method now includes a statusComment parameter. Ensure that all usages of this method, including in production code, handle this new parameter correctly to avoid unexpected behavior.

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 could prevent potential issues with invalid email addresses being processed.

);
}

if (emailChanged) {
Copy link

Choose a reason for hiding this comment

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

[⚠️ correctness]
The emailChanged flag is used to determine if the email update should be propagated to the members.member table. Ensure that this flag is correctly set only when the email update is successful to avoid inconsistent states.

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.

[💡 maintainability]
The change to use CommonUtils.getAppDomain(this.configService) improves maintainability by centralizing domain retrieval logic. Ensure that CommonUtils.getAppDomain handles all edge cases, such as missing or malformed configuration values.

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