fix: merging dev to main - #715
Open
Priyanka2-Microsoft wants to merge 22 commits into
Open
Priyanka2-Microsoft wants to merge 22 commits into
Priyanka2-Microsoft wants to merge 22 commits into
Conversation
…rove error message parsing in the upload dialog
…e existing document handling in the repository
…-seekable streams
…s and improve error handling
…e JSON stringification
…hen no answer is returned
…er JSON parsing and fallback for string replacements
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
fix: Duplicate Document Upload Creates Multiple UI components and Database Entries
fix: enhance the response in UI
fix: Add formatLabel function to format category labels in filter component
Comment on lines
+222
to
+225
| catch (Exception exception) | ||
| { | ||
| _logger?.LogWarning(exception, "Failed to renew the import lease for document {DocumentId}", documentId); | ||
| } |
Comment on lines
+231
to
+234
| catch (Exception exception) | ||
| { | ||
| _logger?.LogWarning(exception, "Failed to release the import lease for document {DocumentId}", documentId); | ||
| } |
|
|
||
| private static FileStream CreateTemporaryFileStream() | ||
| { | ||
| var temporaryFilePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); |
Comment on lines
+219
to
+221
| catch (OperationCanceledException) when (leaseRenewalCancellation.IsCancellationRequested) | ||
| { | ||
| } |
Comment on lines
+196
to
+198
| catch (MongoWriteException exception) when (exception.WriteError?.Category == ServerErrorCategory.DuplicateKey) | ||
| { | ||
| } |
Comment on lines
+199
to
+201
| catch (MongoCommandException exception) when (exception.Code == 11000) | ||
| { | ||
| } |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
One or more issues must be addressed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR improves document import deduplication and concurrency while enhancing upload, chat, and filter UX.
Changes:
- Adds SHA256-based document IDs and MongoDB import leases.
- Improves upload status/error handling and chat answer parsing.
- Formats filter labels and displays all cached categories.
File summaries
| File | Description |
|---|---|
| App/frontend-app/src/components/uploadButton/uploadButton.tsx | Updated as part of this pull request. |
| App/frontend-app/src/components/filter/filter.tsx | Updated as part of this pull request. |
| App/frontend-app/src/api/chatService.ts | Updated as part of this pull request. |
| App/backend-api/Microsoft.GS.DPS/Storage/Documents/DocumentRepository.cs | Updated as part of this pull request. |
| App/backend-api/Microsoft.GS.DPS/API/KernelMemory/KernelMemory.cs | Updated as part of this pull request. |
Review details
Suppressed comments (1)
App/frontend-app/src/api/chatService.ts:30
- These replacements also run on the actual Markdown answer:
getDisplayAnsweris called forresponse.answer, and the backend returnsanswerObject.Response, whose contract permits Markdown. A legitimate answer consisting of a fenced code block will therefore lose both fences and render as plain text. Limit fence removal to the outer JSON wrapper or preserve the extracted answer text.
.replace(/^```[a-z0-9_-]*\s*/i, "")
.replace(/\s*```\s*$/, "");
- Files reviewed: 5/5 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| importStream.Position = 0; | ||
| var contentHash = await SHA256.HashDataAsync(importStream); | ||
| importStream.Position = 0; | ||
| var documentId = Convert.ToHexString(contentHash).ToLowerInvariant(); |
Comment on lines
+248
to
+250
| if (!renewed) | ||
| { | ||
| throw new InvalidOperationException($"The import lease for document {documentId} is no longer owned by this process."); |
Comment on lines
+154
to
+158
| var existingDocument = await FindByDocumentIdAsync(document.DocumentId); | ||
| if (existingDocument != null) | ||
| { | ||
| document.id = existingDocument.id; | ||
| document.__partitionkey = existingDocument.__partitionkey; |
| onToggle={handleAccordionToggle} | ||
| > | ||
| {keywordFilterInfo && Object.entries(keywordFilterInfo).slice(0,10).map(([category, keywords], index) => ( | ||
| {keywordFilterInfo && Object.entries(keywordFilterInfo).map(([category, keywords], index) => ( |
This branch has not been deployed
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.
Purpose
This pull request introduces several important improvements to document import handling, concurrency, and user experience in both the backend and frontend. The main focus is to ensure that duplicate document uploads are handled safely and efficiently, preventing race conditions and providing better feedback to users.
Backend: Document Import Concurrency and Idempotency
Concurrency-safe document import and deduplication:
KernelMemory.cs).ConcurrentDictionaryto track in-progress imports and prevent concurrent processing of the same document.DocumentRepository.cs). [1] [2] [3] [4]Frontend: User Experience and Robustness
Improved answer formatting and display:
chatService.ts). [1] [2]File upload feedback and error handling:
uploadButton.tsx). [1] [2]UI polish for filters:
filter.tsx). [1] [2]These changes collectively make document imports more reliable and user interactions more intuitive and informative.
Does this introduce a breaking change?
Golden Path Validation
Deployment Validation
What to Check
Verify that the following are valid
Other Information