Skip to content

Conversation

@jmgasper
Copy link
Collaborator

Related to PS-448, PS-450

@jmgasper jmgasper requested a review from kkartunov as a code owner November 18, 2025 00:42
@jmgasper jmgasper merged commit f77b47b into master Nov 18, 2025
2 of 4 checks passed
isLoadingBool: isReprocessingSubmissionBool,
doReprocessSubmission,
}: useManageSubmissionReprocessProps
= useManageSubmissionReprocess(submissionReprocessTopic)

Choose a reason for hiding this comment

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

[⚠️ correctness]
The useManageSubmissionReprocess hook is called with submissionReprocessTopic, which is derived from challengeInfo. Ensure that challengeInfo is always in a valid state before using it to derive submissionReprocessTopic to prevent potential runtime errors.

isReprocessingSubmission
}
doReprocessSubmission={doReprocessSubmission}
canReprocessSubmission={Boolean(

Choose a reason for hiding this comment

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

[⚠️ correctness]
The canReprocessSubmission prop is determined by converting submissionReprocessTopic to a Boolean. Ensure that submissionReprocessTopic is correctly initialized and not undefined or null to avoid unexpected behavior.

topic: 'avscan.action.scan',
})

export const SUBMISSION_REPROCESS_TOPICS = {

Choose a reason for hiding this comment

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

[💡 maintainability]
Consider using a more descriptive name for SUBMISSION_REPROCESS_TOPICS to clarify its purpose and context, such as SUBMISSION_REPROCESS_KAFKA_TOPICS. This can improve maintainability by making the code's intent clearer to future developers.

doPostBusEventAvScan: (submission: Submission) => void
isReprocessingSubmission: IsRemovingType
doReprocessSubmission: (submission: Submission) => void
canReprocessSubmission?: boolean

Choose a reason for hiding this comment

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

[⚠️ correctness]
The canReprocessSubmission prop is marked as optional, but it's used directly without a default value or null check. Consider providing a default value or handling the case where it might be undefined to prevent potential runtime errors.

AV Rescan
</Button>
)}
{props.canReprocessSubmission && (

Choose a reason for hiding this comment

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

[❗❗ security]
The condition props.canReprocessSubmission is used to render the 'Reprocess submission' button. Ensure that canReprocessSubmission is correctly set to true only when the user has the necessary permissions to reprocess a submission. This is important for maintaining proper access control.

props.doReprocessSubmission()
}}
primary
disabled={props.isReprocessingSubmission[props.data.id]}

Choose a reason for hiding this comment

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

[⚠️ correctness]
The disabled attribute is set using props.isReprocessingSubmission[props.data.id]. Ensure that isReprocessingSubmission is correctly initialized and updated to prevent potential runtime errors if props.data.id is not present in the object.


const doReprocessSubmission = useCallback(
async (submission: Submission) => {
if (!topic) {

Choose a reason for hiding this comment

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

[⚠️ correctness]
The topic parameter is checked for truthiness, but there is no validation on its content. Consider validating topic to ensure it is a valid and expected value before proceeding with the reprocess logic.


try {
const payload
= await createSubmissionReprocessPayload(submission)

Choose a reason for hiding this comment

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

[⚠️ correctness]
The createSubmissionReprocessPayload function is awaited, which implies it returns a promise. Ensure that this function handles errors internally or consider wrapping it in a try-catch block to handle any potential errors that might occur during payload creation.

submissionUrl: string
memberHandle: string
memberId: string
submittedDate: string

Choose a reason for hiding this comment

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

[⚠️ correctness]
Consider using a more specific date type, such as Date, instead of string for submittedDate to ensure proper date handling and validation.

export interface RequestBusAPIReprocess {
topic: string
originator: string
timestamp: string

Choose a reason for hiding this comment

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

[⚠️ correctness]
Consider using a more specific date type, such as Date, instead of string for timestamp to ensure proper date handling and validation.

topic: string
originator: string
timestamp: string
'mime-type': string

Choose a reason for hiding this comment

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

[💡 style]
Consider using camelCase for mime-type to maintain consistency with JavaScript naming conventions.

const memberHandle = submissionInfo.submitterHandle ?? submissionInfo.createdBy
const submittedDateValue = submissionInfo.submittedDate

if (!submissionId) {

Choose a reason for hiding this comment

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

[💡 readability]
Consider using a more descriptive error message, such as 'Submission ID is missing or invalid', to provide clearer context for debugging.

? challengeId.toString()
: ''
if (!normalizedChallengeId) {
throw new Error('Challenge id is not valid')

Choose a reason for hiding this comment

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

[💡 readability]
Consider using a more descriptive error message, such as 'Challenge ID is missing or invalid', to provide clearer context for debugging.

}

if (!submissionUrl) {
throw new Error('Submission url is not valid')

Choose a reason for hiding this comment

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

[💡 readability]
Consider using a more descriptive error message, such as 'Submission URL is missing or invalid', to provide clearer context for debugging.


const normalizedMemberId = memberId ? memberId.toString() : ''
if (!normalizedMemberId) {
throw new Error('Member id is not valid')

Choose a reason for hiding this comment

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

[💡 readability]
Consider using a more descriptive error message, such as 'Member ID is missing or invalid', to provide clearer context for debugging.

}

if (!memberHandle) {
throw new Error('Member handle is not valid')

Choose a reason for hiding this comment

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

[💡 readability]
Consider using a more descriptive error message, such as 'Member handle is missing or invalid', to provide clearer context for debugging.

? submittedDate.toISOString()
: ''
if (!submittedDateIso) {
throw new Error('Submitted date is not valid')

Choose a reason for hiding this comment

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

[💡 readability]
Consider using a more descriptive error message, such as 'Submitted date is missing or invalid', to provide clearer context for debugging.

}

return filter
return qs.stringify(params, { arrayFormat: 'brackets', skipNulls: true })

Choose a reason for hiding this comment

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

[⚠️ correctness]
Consider specifying the encode option in qs.stringify to ensure consistent encoding behavior across different environments. This can prevent potential issues with special characters in query parameters.

export function getSubmissionReprocessTopic(
challenge?: Challenge,
): string | undefined {
const normalizedType = challenge?.type?.name

Choose a reason for hiding this comment

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

[⚠️ correctness]
The use of replace(/\s+/g, '') to normalize the challenge type name may lead to unexpected results if the challenge type contains multiple words separated by spaces. Consider using a more robust normalization approach if the challenge types are expected to have spaces.

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