refactor: improve error handling and logging across multiple components#634
Open
Ayaz-Microsoft wants to merge 4 commits into
Open
refactor: improve error handling and logging across multiple components#634Ayaz-Microsoft wants to merge 4 commits into
Ayaz-Microsoft wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses code-quality findings by tightening error handling/logging and reducing unused code across the deployment script, frontend UI, and backend API/services.
Changes:
- Backend: refactors several components to use
readonlyfields, improves stream disposal, and adds best-effort exception handling paths. - Frontend: removes/neutralizes unused state/handlers and trims unused imports.
- Deployment tooling: adds documentation clarifying JSON-parse fallback behavior during Bicep params validation.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| Deployment/validate_bicep_params.py | Clarifies fallback behavior when parameters JSON parsing fails. |
| App/frontend-app/src/pages/home/home.tsx | Avoids unused state variables (but leaves some dead state/update paths). |
| App/frontend-app/src/components/sidecarCopilot/sidecar.tsx | Removes unused chat type imports/fields (one unused import remains). |
| App/frontend-app/src/components/searchResult/old.tsx | Removes an unused import. |
| App/frontend-app/src/components/searchBox/searchBox.tsx | Removes unused UI imports and upload logic (leaves unused import/variables). |
| App/frontend-app/src/components/documentViewer/documentViewer.tsx | Avoids unused state value while still passing setter down. |
| App/frontend-app/src/components/chat/modelSwitch.tsx | Removes unused constants/imports. |
| App/frontend-app/src/components/chat/chatRoom.tsx | Removes unused imports/styles/demo code; simplifies state. |
| App/backend-api/Microsoft.GS.DPS/Storage/Documents/DocumentRepository.cs | Small refactor for end-of-day time filtering variable usage. |
| App/backend-api/Microsoft.GS.DPS/Storage/Components/BusinessTransactionRepository.cs | Changes specification casting behavior (now explicit cast). |
| App/backend-api/Microsoft.GS.DPS/Storage/AISearch/TagUpdater.cs | Adds CA1031 suppression for best-effort tag updates. |
| App/backend-api/Microsoft.GS.DPS/API/UserInterface/DataCacheManager.cs | Simplifies keyword consolidation loop logic. |
| App/backend-api/Microsoft.GS.DPS/API/KernelMemory/KernelMemory.cs | Improves resource disposal; adds CA1031 suppression for malformed keyword output handling. |
| App/backend-api/Microsoft.GS.DPS/API/ChatHost/ChatHost.cs | Refactors fields to readonly, updates prompt-path building, adds CA1031 suppression in top-level catch. |
| App/backend-api/Microsoft.GS.DPS.Host/Helpers/TelemetryHelper.cs | Adds CA1031 suppression; adjusts dependency tracking call signature/shape. |
| App/backend-api/Microsoft.GS.DPS.Host/API/UserInterface/UserInterface.cs | Marks static thumbnails dictionary as readonly. |
| App/backend-api/Microsoft.GS.DPS.Host/API/KernelMemory/KernelMemory.cs | Adds null-file guard and removes unused completion flag variable. |
Comments suppressed due to low confidence (1)
App/frontend-app/src/components/searchBox/searchBox.tsx:27
fileInputRefis declared but unused (and the upload input/button is commented out), which will trigger unused-variable linting. Either removeUploadButton/fileInputRefentirely or restore the upload UI so the ref is used.
const UploadButton = () => {
const fileInputRef = useRef<HTMLInputElement>(null);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…y and remove unused import in SearchBox and Sidecar components
- Remove unused fileInputRef in searchBox.tsx (UploadMultipleFiles already removed) - Drop dead selectedDocument state and its setter call in home.tsx - Drop dead widthClass state and its resize useEffect in home.tsx - Use locally computed sessionId when constructing new ChatSession; remove unused field - Log exception in getKeywords catch block instead of swallowing silently - Use TrackDependency overload that maps wrapper params to telemetry dependencyName/data correctly Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
App/frontend-app/src/pages/home/home.tsx:446
handleChatWithDocumentno longer uses itsdocumentparameter. With the repo's ESLint rules, unused args should be prefixed with_or removed to avoid@typescript-eslint/no-unused-varswarnings.
function handleChatWithDocument(document: Document) {
setShowCopilot(true);
if (headerMenuTabsRef.current && showCopilot === false) {
headerMenuTabsRef.current.scrollIntoView({ behavior: "smooth" });
}
}
- TelemetryHelper: make TrackDependency args fully positional (avoids non-trailing named-arg pitfall) - KernelMemory: remove unused 'using DnsClient.Internal;' - KernelMemory.getKeywords: catch JsonException specifically before general fallback - ChatHost: fix 'occured' -> 'occurred' in user-facing error message - searchBox: drop dead UploadButton component and its usage Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Code quality standard findings fixes - improve error handling and logging across multiple components
Does this introduce a breaking change?
Golden Path Validation
Deployment Validation
What to Check
Verify that the following are valid
Other Information