feat(deployments): auto-resolve course groups on deployment create - #170
Merged
Conversation
Move course_groups get-or-create out of the frontend wizard and into DeploymentService. For every group referenced by the incoming stack assignments we now look up an existing CourseGroup by (course_id, name) or create one, and backfill course_group_id on the request payload so deploy_tasks can stamp the FK onto DeploymentInstanceAccess rows. This guarantees students see their credentials via /api/v1/student/ even on the very first deployment of a course — previously the wizard had to bootstrap the course_groups rows itself, which could fail and either abort the deploy or leave group_id NULL on credential rows.
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.
Summary
Moves
course_groupsget-or-create out of the frontend wizard and intoDeploymentService.create_deployment. For every group referenced by the incomingstack_assignments, the service now:CourseGrouprow by(course_id, name), or creates one if missing.course_group_idon the request payload when the client passednull, sodeploy_taskscan stamp the FK ontoDeploymentInstanceAccessrows.Motivation
Previously, the wizard had to:
courses.idfor the selected Keycloak group viaGET /courses,course_groupsrows viaPOST /courses/{id}/groupsbefore submitting the deployment.That flow had two failure modes:
coursesrow yet, nocourse_groupsrows yet), the wizard couldn't resolve the internal course id and submittedcourse_group_id: null. Credential rows then hadgroup_id = NULLand students lost visibility via/api/v1/student/.course_groupsbootstrapping hit an HTTP error, it aborted the deployment with a user-facing toast — even though the backend already hadCourseget-or-create logic and was capable of doing the same for groups.Doing this server-side guarantees that
course_group_idis always populated, regardless of which client submits the deployment.Changes
src/services/deployment_service.py: after the existingCourseget-or-create, build a{group_name: course_group_id}map for the course; create missingCourseGrouprows; backfillcourse_group_idon anystack_assignments[].groups[]entry that arrived withNone.Companion PR
DoziLab/appstore-frontend—refactor/move-course-group-resolution-to-backend→stagingTest plan
coursesorcourse_groupsrows) — confirmcourse_groupsrows are auto-created andDeploymentInstanceAccess.group_idis non-null.course_groupsare reused (no duplicates), names are matched case-sensitively as before.course_group_id(older frontend build) — confirm the value is honoured, not overwritten.