Title: fix(forks): stop copying connector-managed knowledge base documents by icecrasher321 · Pull Request #6818 · simstudioai/sim · GitHub
Open Graph Title: fix(forks): stop copying connector-managed knowledge base documents by icecrasher321 · Pull Request #6818 · simstudioai/sim
X Title: fix(forks): stop copying connector-managed knowledge base documents by icecrasher321 · Pull Request #6818 · simstudioai/sim
Description: Summary A fork copies a knowledge base's documents but never its connectors — deliberate, per copyForkResourceContainers ("the child is a content snapshot without live sync"). What was not deliberate is that connector-sourced documents were copied anyway, arriving with connector_id nulled and external_id, content_hash, source_url and the original uploaded_at intact. That copy is unreachable by the sync engine, which scopes every existing / tombstone / exclusion lookup to eq(document.connectorId, connectorId) (sync-engine.ts:828-885). It can never be updated, reconciled, or purged. doc_connector_external_id_idx — UNIQUE (connector_id, external_id) WHERE deleted_at IS NULL — does not constrain it either, because Postgres treats NULLs as distinct. So attaching a connector in the child re-ingests every page as a new row on top of the snapshot. And since the copy loop filtered only deleted_at / archived_at, each hop also re-copied the previous hop's orphans: inherited (fork_document_*) connector (UUID) total prod 0 56 56 UAT (fork + attach connector) 56 56 112 staging (fork + attach connector) 112 56 168 Three rows per page, so a knowledge search returns the same page three times — one of them frozen at the fork date, serving content nothing will ever refresh. This was reported from a real prod → UAT → staging chain: 191 documents for ~56 Confluence pages. The change Exclude connector-managed documents at all four doors a document can enter a fork through: Site Change copyForkResourceContent whole-KB page query isNull(document.connectorId) createForkDocumentPlaceholders (in the fork tx) isNull(document.connectorId) planForkMappedKbDocumentCopies (sync-only, doc → already-mapped KB) isNull(document.connectorId) contentPlan.documents fill loop explicit source.connectorId guard The placeholder path matters as much as the copy loop. Filtering only the content phase would leave a referenced connector document with an archived placeholder and a persisted knowledge_document mapping pointing at it, with nothing behind it to ever fill it. Skipped on both sides, its document-selector reference clears like any other uncopied document's — existing, documented behavior. The fourth guard covers one case only: a payload planned by a pre-change worker and filled by a new one mid-rollout. It throws into the existing per-document cleanup, which drops the placeholder and clears its references — the same outcome the new planner produces. A document whose connector was deleted in the source already has a null connector_id (the FK is ON DELETE SET NULL) and is static content there too, so it still copies. That falls out of the predicate rather than needing a special case. One count(*) per copied KB logs what was left behind — a fully connector-synced KB now forks to zero documents, and without this there would be nothing anywhere explaining why. Docs New #### Connector-synced documents are not copied under "Knowledge bases and documents": the sharp edge in a warn callout, the reasoning, and the two workarounds (re-add the connector for live content; download-and-upload for a frozen snapshot). The at-a-glance row links to it. Also corrected the adjacent line, which claimed "Documents that the forked workflows actually reference are included" — the fork copies every document in the KB; only the placeholder pre-creation was ever reference-scoped. Not in scope This stops new duplication; it does not clean up KBs already in this state. No follow-up is needed — the known-affected knowledge bases have already been corrected manually, out of band. No backfill or migration ships with this PR. Type of Change Bug fix Testing bun run test ee/workspace-forking → 39 files, 601 tests passed. type-check, biome check and check:api-validation all clean. Four new tests. The predicates are the whole fix, and the row-queue mocks return whatever is enqueued regardless of the where, so three of them assert the condition tree via flattenMockConditions + schemaMock — the helper that exists for exactly this: whole-KB page query excludes connector_id placeholder pre-creation excludes it, and records no knowledge_document mapping mapped-KB candidate query excludes it U-docs fill refuses a connector-managed source: charges nothing, downloads nothing, reports a knowledge-document failure for cleanup Also flipped the planForkMappedKbDocumentCopies fixture from connectorId: 'connector-1' to null — it was describing a document the planner must now never place. Reviewers should focus on the placeholder/content-phase agreement (they must skip the same set or a mapping dangles) and on whether losing connector content at fork time is the right trade for the affected teams — a fully-synced KB now forks empty, which is a real behavior change the docs callout is there to set expectations for. Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)
Open Graph Description: Summary A fork copies a knowledge base's documents but never its connectors — deliberate, per copyForkResourceContainers ("the child is a content snapshot without live sync"). What wa...
X Description: Summary A fork copies a knowledge base's documents but never its connectors — deliberate, per copyForkResourceContainers ("the child is a content snapshot without live sync&quo...
Opengraph URL: https://github.com/simstudioai/sim/pull/6818
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:9ed9adf2-4178-9775-3bec-8457ec76ed25 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C892:277BD5:E442CD:138A78E:6AFB5DE6 |
| html-safe-nonce | dd356ff1ee1e4e4c8773e63db1ffe78382ae945198a14d9193e62d60f46cad6e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODkyOjI3N0JENTpFNDQyQ0Q6MTM4QTc4RTo2QUZCNURFNiIsInZpc2l0b3JfaWQiOiI1MTg3NDI2Mzg2MjUxMDQ2Mzc0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9b29b1813305e015f1a692bff4efbfe0af71cdb6cce2390d0f84c5faed9574d2 |
| hovercard-subject-tag | pull_request:4308308667 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/6818/files |
| twitter:image | https://avatars.githubusercontent.com/u/17950982?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/17950982?s=400&v=4 |
| og:image:alt | Summary A fork copies a knowledge base's documents but never its connectors — deliberate, per copyForkResourceContainers ("the child is a content snapshot without live sync"). What wa... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | ea33d13c96d0ff66bd8fa906b193d2213536b78cb06b0c50a4632c58b1418f94 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 59ef97164c52cf59bd10558ddec9c4f482763988 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width