-
Notifications
You must be signed in to change notification settings - Fork 15
Feature/mooclet params modal and view #2793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: experiment-design-refresh
Are you sure you want to change the base?
Feature/mooclet params modal and view #2793
Conversation
…feature/mooclet-params-modal-and-view
...ts-configurable-policy-parameters-form/ts-configurable-policy-parameters-form.component.html
Show resolved
Hide resolved
...ts-configurable-policy-parameters-form/ts-configurable-policy-parameters-form.component.html
Outdated
Show resolved
Hide resolved
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
| let message = `[Algorithm Change] Assignment algorithm changed from ${oldAlgorithm} to ${experiment.assignmentAlgorithm}.`; | ||
| message += wasMooclet && 'Will delete old Mooclet resources after successful update.'; | ||
| message += isNowMooclet && 'Will create new Mooclet resources as part of update.'; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem: && operator doesn't work as expected for string concatenation. If wasMooclet is true, it evaluates to the string, but if false, it adds false to the message. Fix:
let message = `[Algorithm Change] Assignment algorithm changed from ${oldAlgorithm} to ${experiment.assignmentAlgorithm}.`;
if (wasMooclet) message += ' Will delete old Mooclet resources after successful update.';
if (isNowMooclet) message += ' Will create new Mooclet resources as part of update.';
| // } | ||
| // return await this.updateUpgradeExperiment(manager, params); | ||
| // }); | ||
| // } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider removing this commented code.
| // when transitioning away from Mooclet, delete the old refs after successful experiment update | ||
| if (params.moocletRefToDelete) { | ||
| await this.moocletExperimentRefRepository.delete(params.moocletRefToDelete.id); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem: The deletion uses moocletExperimentRefRepository.delete() directly instead of using the transaction manager. This means the deletion may not be part of the transaction and could cause:
- Orphaned refs if the transaction rolls back after deletion
- Loss of atomicity
Fix:
if (params.moocletRefToDelete) {
await manager.delete(MoocletExperimentRef, params.moocletRefToDelete.id);
}
| } | ||
|
|
||
| // when transitioning to Mooclet, create the Mooclet resources | ||
| if (this.isMoocletExperiment(updatedExperiment.assignmentAlgorithm)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double Deletion Risk in Algorithm Change Flow
Location: MoocletExperimentService.ts:1507-1535 The code deletes mooclet resources in two places:
- Inside
syncUpdateWithMoocletAlgorithmTransitiontransaction (line 185) - deletes UpGrade DB ref - Outside transaction in
handlePotentialMoocletAssignmentAlgorithmChange(line 1515) - deletes external Mooclet API resources
Issue: If the external Mooclet deletion fails (line 1515), you've already deleted the UpGrade DB reference (line 185), making it impossible to retry cleanup later. This creates orphaned Mooclet API resources with no way to track them. Recommendation: Consider one of these approaches:
- Option A: Only delete the UpGrade ref inside the transaction, move ALL external deletions outside
- Option B: Keep a "soft delete" flag on refs to track failed cleanups
- Option C: Add a cleanup job to handle orphaned resources
|
I added a few review comments suggested by Claude. Feel free to resolve or ignore them. |
@amurphy-cl open to any wordsmithing of the language