Skip to content

[PROD] - Jan 26 v1#25

Merged
kkartunov merged 6 commits into
masterfrom
develop
Jan 13, 2026
Merged

[PROD] - Jan 26 v1#25
kkartunov merged 6 commits into
masterfrom
develop

Conversation

@kkartunov

Copy link
Copy Markdown
Contributor

@kkartunov kkartunov requested a review from jmgasper January 13, 2026 08:34
state: 'END',
operator: AutopilotOperator.SYSTEM,
projectStatus: challenge.status,
skipReviewCompletionCheck: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[❗❗ correctness]
The addition of skipReviewCompletionCheck: true could potentially bypass important review completion checks. Ensure that this change is intentional and that all necessary conditions are met before skipping these checks. Consider documenting the rationale for this change to avoid confusion in future maintenance.

expect(financeApiService.generateChallengePayments).toHaveBeenCalledWith(
challenge.id,
);
expect(kafkaService.produce).toHaveBeenCalledWith(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[💡 maintainability]
The produce method of kafkaService is being called with a payload that includes the topic key, which seems redundant since the topic is already specified as the first argument. Consider removing the topic key from the payload to avoid redundancy and potential confusion.

payload,
};

await this.kafkaService.produce(KAFKA_TOPICS.CHALLENGE_UPDATED, message);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ reliability]
Consider adding a retry mechanism for the Kafka message production in case of transient failures. This can improve the reliability of the message delivery.

`Published challenge update for completed challenge ${challengeId}.`,
);
} catch (error) {
const err = error as Error;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ correctness]
The catch block logs the error but does not rethrow it or handle it in a way that would allow the caller to know that the operation failed. Consider whether the caller should be informed of this failure to take appropriate action.

: null;

if (
this.isAppealsPhaseName(updatedPhase.name) &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ correctness]
The condition previousScheduledStart !== updatedScheduledStart is used to determine if successor phases should be rescheduled. Consider if there are scenarios where the scheduled start date might change but not require rescheduling, or vice versa. Ensure this logic aligns with business requirements.

};

const scheduledJobId = await this.schedulePhaseTransition(nextPhaseData);
const scheduledJobId = await this.reschedulePhaseTransition(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ design]
The method reschedulePhaseTransition is used here, replacing schedulePhaseTransition. Ensure that this change is intentional and that reschedulePhaseTransition handles all necessary logic for both scheduling and rescheduling phases.

"source": "FinanceApiService",
"details": {
"url": "https://api.topcoder-dev.com/v6/finance/challenges/8a8423ed-62cc-4760-bc81-34a0c1a6b27a",
"token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik5VSkZORGd4UlRVME5EWTBOVVkzTlRkR05qTXlRamxETmpOQk5UYzVRVUV3UlRFeU56TTJRUSJ9.eyJpc3MiOiJodHRwczovL3RvcGNvZGVyLWRldi5hdXRoMC5jb20vIiwic3ViIjoib1VNc2VNbmM1UlhtZVVYSUU1VEZhVmpKQThhWjE3bGNAY2xpZW50cyIsImF1ZCI6Imh0dHBzOi8vbTJtLnRvcGNvZGVyLWRldi5jb20vIiwiaWF0IjoxNzY3NTA2MjY3LCJleHAiOjE3Njc1OTI2NjcsInNjb3BlIjoiYWxsOmNoYWxsZW5nZXMgcmVhZDpjaGFsbGVuZ2VzIHdyaXRlOmNoYWxsZW5nZXMgdXBkYXRlOnJldmlld19zdW1tYXRpb24gcmVhZDpyZXZpZXdfc3VtbWF0aW9uIGRlbGV0ZTpyZXZpZXdfc3VtbWF0aW9uIGNyZWF0ZTpyZXZpZXdfc3VtbWF0aW9uIGFsbDpyZXZpZXdfc3VtbWF0aW9uIHJlYWQ6YnVzX3RvcGljcyB3cml0ZTpidXNfYXBpIHJlYWQ6cmVzb3VyY2VzIHdyaXRlOnJlc291cmNlcyBkZWxldGU6cmVzb3VyY2VzIHVwZGF0ZTpyZXNvdXJjZXMgYWxsOnJlc291cmNlcyBjcmVhdGU6Y2hhbGxlbmdlcyBjcmVhdGU6cmVzb3VyY2VzIHVwZGF0ZTpjaGFsbGVuZ2VzIGNyZWF0ZTpwYXltZW50cyBjcmVhdGU6cmV2aWV3X29wcG9ydHVuaXR5IHJlYWQ6cmV2aWV3X29wcG9ydHVuaXR5IHVwZGF0ZTpyZXZpZXdfb3Bwb3J0dW5pdHkgYWxsOnJldmlld19vcHBvcnR1bml0eSIsImd0eSI6ImNsaWVudC1jcmVkZW50aWFscyIsImF6cCI6Im9VTXNlTW5jNVJYbWVVWElFNVRGYVZqSkE4YVoxN2xjIn0.fnPQHubMhoRtBcV9IIvWG1bdvvumiFxZLwwUAFNEVVOhhbpFJ4x4XmA9rvjqX1B7ElR_000wyJTj338v5tajop518gDLKKCP8hOVQnlIDu2zxzd598yNeKmW4HpFdpj_mApgrWW3FU8UaLPP4-qA-N5XnYUg6LI_zPtxXDusuzx7cu0e991_vG2azwExmQR0lk_k7z6CRFo0Q4Ntg_trna3ggsGcT-o8dblRHiKiF0WYGW8tG3LMM7jXHoF2MRO59edHSvSafpd4-87tW1I2HsPcG0cH8YYrWSiRSvRlLKbO8HyAmAQ2-FMNSVH_hFuSmyTNPqCqxFUHKTfQBFvfnw",

Check warning

Code scanning / Trivy

JWT token Medium

Artifact: 8a8423ed-62cc-4760-bc81-34a0c1a6b27a.json
Type:
Secret JWT token
Severity: MEDIUM
Match: "token": "***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************",
"source": "FinanceApiService",
"details": {
"url": "https://api.topcoder-dev.com/v6/finance/challenges/8a8423ed-62cc-4760-bc81-34a0c1a6b27a",
"token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik5VSkZORGd4UlRVME5EWTBOVVkzTlRkR05qTXlRamxETmpOQk5UYzVRVUV3UlRFeU56TTJ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qA-N5XnYUg6LI_zPtxXDusuzx7cu0e991_vG2azwExmQR0lk_k7z6CRFo0Q4Ntg_trna3ggsGcT-o8dblRHiKiF0WYGW8tG3LMM7jXHoF2MRO59edHSvSafpd4-87tW1I2HsPcG0cH8YYrWSiRSvRlLKbO8HyAmAQ2-FMNSVH_hFuSmyTNPqCqxFUHKTfQBFvfnw",

Check warning

Code scanning / Trivy

JWT token Medium

Artifact: 8a8423ed-62cc-4760-bc81-34a0c1a6b27a.json
Type:
Secret JWT token
Severity: MEDIUM
Match: "token": "***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************",
},
);

challengeApiService.advancePhase.mockImplementation(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ maintainability]
The advancePhase mock implementation is quite complex and could be simplified by using a data-driven approach or extracting the logic into a helper function. This would improve maintainability and readability.

},
);

await scheduler.advancePhase(payload);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ correctness]
Consider adding assertions to verify the state of reviewPhase and appealsPhase after the advancePhase calls. This would ensure that the phases are correctly updated and improve the test's robustness.

): void {
this.phaseChainCallback = callback;
Logger.log(
`[PHASE CHAIN] Phase chain callback registered (pid ${process.pid}).`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[💡 maintainability]
Consider using this.logger instead of Logger.log for consistency with other logging statements in the class.

await this.reviewService.getCompletedReviewCountForPhase(
data.phaseId,
);
if (!data.skipReviewCompletionCheck) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ correctness]
The addition of the skipReviewCompletionCheck flag introduces a conditional path that could lead to skipping necessary review completion checks. Ensure that this flag is used appropriately and that its implications are well understood.

@@ -879,7 +885,6 @@ export class SchedulerService implements OnModuleInit, OnModuleDestroy {
(phase) =>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[❗❗ correctness]
The removal of the !phase.actualStartDate condition may lead to phases being opened that should not be. Verify that this change aligns with the intended logic for opening appeals-related phases.

data.challengeId,
data.projectId,
data.projectStatus,
data.projectStatus ?? ChallengeStatusEnum.ACTIVE,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[💡 design]
The use of the nullish coalescing operator (??) to default data.projectStatus to ChallengeStatusEnum.ACTIVE is a good practice. Ensure that ChallengeStatusEnum.ACTIVE is the appropriate default status in all contexts where this is applied.

return;
}

const context = await this.resolveProjectContext(data);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ reliability]
Ensure that the resolveProjectContext method handles all potential error cases, especially when interacting with external services like challengeApiService. Consider adding more robust error handling or retries if necessary.

},
});

if (updateResult.count === 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ maintainability]
The updateResult.count === 0 check is used to determine if the phase was updated, but it might be more robust to handle this scenario explicitly with a specific error or log message to ensure clarity on why the transaction is returning early.

},
});

if (updateResult.count === 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ maintainability]
The updateResult.count === 0 check is used again here. Consider adding a specific log message or error handling to clarify why the transaction is returning early, similar to the previous block.

durationSeconds > 0 &&
desiredStartSource
) {
const desiredStartDate = new Date(desiredStartSource);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ correctness]
The conversion of desiredStartSource to a Date object without validation could lead to unexpected behavior if desiredStartSource is not a valid date string. Consider adding validation to ensure desiredStartSource is a valid date before conversion.

if (!dateA || !dateB) {
return false;
}
return new Date(dateA).getTime() === new Date(dateB).getTime();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ correctness]
The datesAreSame method converts both dates to Date objects and compares their time values. Ensure that the input dates are valid to prevent potential runtime errors.

prizeSets: IChallengePrizeSet[];
terms: any[];
skills: any[];
skills: { id: string }[];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ correctness]
Changing the type of skills from any[] to { id: string }[] improves type safety by specifying the expected structure of skill objects. However, ensure that all parts of the codebase interacting with skills are updated to handle this new structure to prevent runtime errors.

@kkartunov kkartunov merged commit 5301542 into master Jan 13, 2026
8 of 9 checks passed
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.

3 participants