Skip to content

fix: preserve workspaceId in bulkUpdateChatflows + optional template name sync#1071

Merged
ct3685 merged 1 commit into
stagingfrom
ct/fix-bulk-update-chatflow-workspace
May 15, 2026
Merged

fix: preserve workspaceId in bulkUpdateChatflows + optional template name sync#1071
ct3685 merged 1 commit into
stagingfrom
ct/fix-bulk-update-chatflow-workspace

Conversation

@ct3685
Copy link
Copy Markdown

@ct3685 ct3685 commented May 15, 2026

Summary

  • Bug fix: bulkUpdateChatflows was spreading the admin template entity without overriding workspaceId, causing every bulk template push to overwrite each user's chatflow workspace with the template owner's workspace ('Default Workspace'). This is the root cause of the repeated prod SQL hotfixes.
  • Enhancement: Adds an optional updateName flag so admins can choose to propagate the template name to all user copies during a bulk push (off by default — no behaviour change without opt-in).
  • Data migration: 1770000000002-FixBulkUpdateChatflowWorkspace idempotently repairs chatflows already corrupted by previous bulk updates across all orgs (generalises the prod SQL fix, registered in postgresMigrations).

Changes

File Change
packages/server/src/services/chatflows/index.ts Add workspaceId: targetChatflow.workspaceId override + options.updateName conditional name logic
packages/server/src/controllers/chatflows/index.ts Extract and pass options from request body
packages/ui/src/api/chatflows.js Accept and forward options in PUT body
packages-answers/ui/src/Admin/Chatflows/index.tsx Replace raw button click with confirmation dialog + "Also update chatflow name" checkbox
packages/server/src/database/migrations/postgres/aai/1770000000002-FixBulkUpdateChatflowWorkspace.ts New idempotent data migration
packages/server/src/database/migrations/postgres/index.ts Import + register new migration

Root Cause

// Before — templateChatflow.workspaceId leaked onto every user's copy
const updatedChatflow = {
    ...templateChatflow,   // workspaceId from admin workspace leaked in
    id: targetChatflow.id,
    userId: targetChatflow.userId,
    // workspaceId NOT overridden
}

// After — workspace always preserved from the target
const updatedChatflow = {
    ...templateChatflow,
    id: targetChatflow.id,
    userId: targetChatflow.userId,
    workspaceId: targetChatflow.workspaceId,  // fixed
    name: options?.updateName ? templateChatflow.name : targetChatflow.name,
}

Test Plan

  • Run migration on staging DB — chatflows in Default Workspace with parentChatflowId move to Personal Workspace
  • Trigger bulk update via Admin Chatflows UI — user chatflows stay in their Personal Workspace after push
  • Confirm "Update Selected" now opens a confirmation dialog before acting
  • Check "Also update chatflow name" — names synced to template post-update
  • Leave checkbox unchecked — names preserved as-is

…sync

- bulkUpdateChatflows was spreading the admin template entity without
  overriding workspaceId, causing all bulk-updated chatflows to land in
  the template owner's workspace (Default Workspace) instead of each
  user's Personal Workspace
- Add workspaceId: targetChatflow.workspaceId to the override object
- Add optional options.updateName flag so admins can choose to propagate
  the template name to user copies (off by default, preserving existing
  behaviour)
- Wire options through controller and API client
- Replace the raw Update button in Admin Chatflows UI with a confirmation
  dialog that exposes the updateName checkbox
- Add migration 1770000000002 to repair chatflows already corrupted by
  prior bulk updates (idempotent, all orgs, same logic as prod SQL fix)
@ct3685 ct3685 added bug Something isn't working backend ui sidekick labels May 15, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
answerai-docs Building Building Preview May 15, 2026 4:53pm
the-answerai Building Building Preview May 15, 2026 4:53pm

Request Review

@ct3685
Copy link
Copy Markdown
Author

ct3685 commented May 15, 2026

@copilot please review this pr, thanks!

Copy link
Copy Markdown

Copilot AI commented May 15, 2026

@copilot please review this pr, thanks!

Reviewed the PR at commit 72f32ea — no blocking issues found in this change set. The workspaceId preservation fix, optional updateName wiring, and migration intent all look correct. Current failing checks appear unrelated to this PR diff (Claude review job missing API/OAuth token, plus existing lint errors in other files). If you want, I can follow up in a separate PR to address those CI failures.

Copilot finished work on behalf of ct3685 May 15, 2026 17:03
@ct3685 ct3685 merged commit 3e166d6 into staging May 15, 2026
6 of 9 checks passed
@ct3685 ct3685 deleted the ct/fix-bulk-update-chatflow-workspace branch May 15, 2026 17:10
ct3685 added a commit that referenced this pull request May 15, 2026
## 🚀 Release: Staging to Production

**Release Date:** 2026-05-15

### Changes in this release

- fix: add missing KeyboardArrowDownIcon import (7d7216e)
- feat: collapsible template banner with count pill, green/amber
theming, always-green badge (#1074) (99e0c8b)
- feat: turn template banner green when all chatflows are up to date
(#1073) (7314af5)
- fix: reload page after bulk chatflow update and show in-progress state
(#1072) (5ca478d)
- fix: preserve workspaceId in bulkUpdateChatflows + optional template
name sync (#1071) (3e166d6)
- chore: update dependencies for improved compatibility and
functionality (#1070) (6451d83)
- fix: restore Atlassian MCP OAuth by removing stale Passport dependency
(#1068) (00bae11)

---
*This PR is automatically created/updated when commits are pushed to
staging.*
*Merging this PR will trigger the release workflow to create a new
GitHub release.*

---------

Co-authored-by: Cameron Taylor <50385537+ct3685@users.noreply.github.com>
Co-authored-by: Cameron Taylor <cameron@lastrev.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend bug Something isn't working enhancement New feature or request patch ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants