Merged
Conversation
OpenAPI ChangesShow/hide ## Changes for v0.yaml:Unexpected changes? Ensure your branch is up-to-date with |
Comment on lines
88
to
95
| if not clone_course_run: | ||
| continue | ||
|
|
||
| new_run_tag = B2B_RUN_TAG_FORMAT.format( | ||
| year=now_in_utc().year, | ||
| contract_id=contract.id, | ||
| ) | ||
| source_id = CourseKey.from_string(clone_course_run.courseware_id) | ||
| new_readable_id = f"{UAI_COURSEWARE_ID_PREFIX}{contract.organization.org_key}+{source_id.course}+{new_run_tag}" | ||
|
|
||
| # Check if run already exists | ||
| if CourseRun.objects.filter( | ||
| course=course, courseware_id=new_readable_id | ||
| ).exists(): | ||
| if CourseRun.objects.filter(course=course, b2b_contract=contract).exists(): | ||
| skipped_count += 1 | ||
| log.debug( | ||
| "Contract run already exists for course %s in contract %s", |
There was a problem hiding this comment.
Bug: The create_program_contract_runs task incorrectly skips creating new course runs, blocking the intended feature of allowing multiple, indexed reruns for the same course and contract.
Severity: MEDIUM
Suggested Fix
Remove the if CourseRun.objects.filter(course=course, b2b_contract=contract).exists(): check from the create_program_contract_runs task. Let the create_contract_run function handle the logic for creating new indexed runs or raising errors, as it is designed to do.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: b2b/tasks.py#L88-L95
Potential issue: The task `create_program_contract_runs` checks if any `CourseRun`
exists for a given `course` and `b2b_contract` and skips creation if one is found. This
check is too broad and conflicts with the underlying `create_contract_run` API, which
was updated to support multiple, indexed reruns for the same course and contract (e.g.,
with keys ending in `1T`, `2T`, etc.). Because the task skips unconditionally if any run
exists, it prevents the new indexed rerun functionality from ever being used, making the
feature inaccessible through the primary workflow.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Carey P Gumaer
James Kachel
Dan Subak