Skip to content

Fix knowledge file sync - #527

Open
Hoa Nguyen (nguhoa) wants to merge 3 commits into
mainfrom
nguhoa/synclib
Open

Hoa Nguyen (nguhoa) wants to merge 3 commits into
mainfrom
nguhoa/synclib

Conversation

@nguhoa

Copy link
Copy Markdown
Contributor

Fix knowledge file sync

Copilot AI balanced review requested due to automatic review settings November 19, 2026 01:09
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0a661635-bab8-4535-9e6e-5eb3e45d0476

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Concurrent local and cloud edits to a knowledge file’s description can silently overwrite the local description during pull because attachment metadata conflicts are not detected.

1 open issue
What changed in this PR

This PR improves knowledge-file synchronization between local Copilot Studio workspaces and Dataverse, covering sidecar descriptions, cloud replacements, and upload filenames.

Changes:

  • Reads authored descriptions and preserves local metadata edits when the cloud only reuploads file content.
  • Protects replacement files during deletion cleanup and supports filenames that cannot be sent in HTTP headers.
  • Adds regression tests for metadata, replacement, and push-retry behavior.
File Description
src/​CopilotStudio.Sync/​WorkspaceSynchronizer.cs Updates metadata handling, retry downloads, and replacement-safe cleanup.
src/​CopilotStudio.Sync/​Dataverse/​SyncDataverseClient.cs Uses an encoded query parameter for header-incompatible filenames.
src/​CopilotStudio.Sync/​ConnectionReferenceStore.cs Extracts a read helper for already-listed files.
src/​CopilotStudio.Sync.UnitTests/​SkillFolderLayoutTests.cs Tests skill asset replacements and authored descriptions.
src/​CopilotStudio.Sync.UnitTests/​PushConcurrencyRetryTests.cs Tests knowledge-file metadata and payload handling during retries.
src/​CopilotStudio.Sync.UnitTests/​KnowledgeFileUnifyTests.cs Tests description edits, reuploads, and replacement cleanup.
src/​CopilotStudio.Sync.UnitTests/​Dataverse/​DataverseRetryPolicyTests.cs Tests filename transport through headers and query parameters.
src/​CopilotStudio.Sync.UnitTests/​CliAgentRoundTripReadTests.cs Allows shared sync infrastructure in fixture setup.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 19, 2026 02:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the knowledge-file synchronization and upload changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@MattB-msft

Copy link
Copy Markdown
Member

Review finding: [P1] Pull can silently discard a locally edited knowledge-file description

Reviewed commit: 0fa18e4309a57a09646f2252a66ccfde694fd738.

In src/CopilotStudio.Sync/WorkspaceSynchronizer.cs:1893-1897, MergeKnowledgeFileDescriptions handles only remote upserts and skips BotComponentDelete. Knowledge files are also excluded from the general conflict merge at lines 616-620.

Reproduction:

  1. Edit an existing knowledge file's description locally in its sidecar.
  2. Delete that component in the cloud.
  3. Pull the remote changes.

The remote deletion remains in the merged changeset, so UpdateWorkspaceDirectoryAsync deletes the locally edited sidecar and payload (lines 4817-4824) without reporting a merge conflict. The newly supported local description edit is lost.

Requested change: Treat a remote deletion against a local knowledge-file description update as a conflict, preserve the local files for resolution, and add an end-to-end pull regression covering that sequence.

I would block merging on this data-loss path. This finding is based on the visible source and callers; no external dependencies were decompiled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants