fix: dev to main merge - #1141
Conversation
fix: updated the team upload functionality while rerunning the post deployment script to fix duplicate team issue
Coverage Report •
|
||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
This PR improves the team-configuration upload/seed workflow by making team configuration persistence idempotent (avoiding duplicate CosmosDB team config documents on re-upload) and by standardizing upload-related telemetry/response payload fields for the uploaded file name.
Changes:
- Updated
TeamService.save_team_configurationto reuse an existing team config document (byteam_id) and update it instead of always inserting a new document. - Standardized upload validation event/log payload key from
filenametofile_namein/upload_team_config. - Removed the pre-upload “delete existing team” behavior from the post-provision upload script so it relies on backend upsert/update behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/backend/services/team_service.py | Adds idempotent save logic by looking up an existing team by team_id and updating instead of always creating. |
| src/backend/api/router.py | Standardizes upload validation event payload key to file_name for consistency. |
| infra/scripts/post-provision/upload_team_config.py | Stops deleting existing teams before upload, relying on backend idempotency instead. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
test: updated the testcases
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/backend/services/team_service.py:183
save_team_configurationcurrently upserts any existing record returned bymemory_context.get_team(team_id). In the CosmosDB implementation,get_teamcan return shared default teams (query includesOR c.is_default=true), so a user uploading a config with the sameteam_idcould overwrite a shared default team configuration.
existing = await self.memory_context.get_team(team_config.team_id)
if existing is not None:
# Preserve immutable identity fields; partition key (session_id)
# cannot change on an upsert.
team_config.id = existing.id
fix: Pin GitHub Actions to commit SHAs
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 26 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/backend/services/team_service.py:185
- When an existing team is found, this method upserts the entire document via
update_team(Cosmos usesupsert_item). Only preservingid/session_id/created/created_bymeans other important fields (notablyuser_idandis_default) will be overwritten by the newly parsed upload. That can accidentally flip a shared default team (is_default=true) into a user-owned/non-default team (or change ownership), affecting visibility and potentially allowing users to overwrite shared defaults by reusing a knownteam_id. Preserve these fields from the existing document (or explicitly block updates to default teams for non-admin callers).
# Preserve immutable identity fields; partition key (session_id)
# cannot change on an upsert.
team_config.id = existing.id
team_config.session_id = existing.session_id
team_config.created = existing.created
Purpose
This pull request focuses on improving the idempotency and event logging consistency of the team configuration upload process. The main changes ensure that re-uploading a team configuration does not create duplicate database entries and that event logging uses a consistent field name.
Team configuration upload and storage improvements:
save_team_configurationmethod inTeamServiceis now idempotent byteam_id: it checks if a team already exists and, if so, updates the existing record instead of creating a new one. This prevents duplicate database entries when re-running the seed script.Event logging consistency:
filenametofile_namein all relevant responses and tracking calls within theupload_team_configendpoint for consistency. [1] [2] [3] [4]Script behavior change:
upload_team_config.py) no longer deletes existing teams before uploading; it relies on the backend's idempotent upsert logic to handle updates.Does this introduce a breaking change?
How to Test
What to Check
Verify that the following are valid
Other Information