Skip to content

refactor: improve error handling and logging across multiple components#634

Open
Ayaz-Microsoft wants to merge 4 commits into
devfrom
codeql-ayaz
Open

refactor: improve error handling and logging across multiple components#634
Ayaz-Microsoft wants to merge 4 commits into
devfrom
codeql-ayaz

Conversation

@Ayaz-Microsoft
Copy link
Copy Markdown
Contributor

Purpose

Code quality standard findings fixes - improve error handling and logging across multiple components

Does this introduce a breaking change?

  • Yes
  • No

Golden Path Validation

  • I have tested the primary workflows (the "golden path") to ensure they function correctly without errors.

Deployment Validation

  • I have validated the deployment process successfully and all services are running as expected with this change.

What to Check

Verify that the following are valid

  • ...

Other Information

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 readonly fields, 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

  • fileInputRef is declared but unused (and the upload input/button is commented out), which will trigger unused-variable linting. Either remove UploadButton/fileInputRef entirely 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.

Comment thread App/frontend-app/src/components/searchBox/searchBox.tsx
Comment thread App/frontend-app/src/components/sidecarCopilot/sidecar.tsx Outdated
Comment thread App/frontend-app/src/pages/home/home.tsx Outdated
Comment thread App/frontend-app/src/pages/home/home.tsx Outdated
Comment thread App/backend-api/Microsoft.GS.DPS/API/ChatHost/ChatHost.cs Outdated
Comment thread App/backend-api/Microsoft.GS.DPS.Host/Helpers/TelemetryHelper.cs
Comment thread App/backend-api/Microsoft.GS.DPS/API/KernelMemory/KernelMemory.cs
Ayaz-Microsoft and others added 2 commits May 13, 2026 19:02
…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>
Copilot AI review requested due to automatic review settings May 14, 2026 06:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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

  • handleChatWithDocument no longer uses its document parameter. With the repo's ESLint rules, unused args should be prefixed with _ or removed to avoid @typescript-eslint/no-unused-vars warnings.
    function handleChatWithDocument(document: Document) {
        setShowCopilot(true);
        if (headerMenuTabsRef.current && showCopilot === false) {
            headerMenuTabsRef.current.scrollIntoView({ behavior: "smooth" });
        }
    }

Comment thread App/backend-api/Microsoft.GS.DPS.Host/Helpers/TelemetryHelper.cs Outdated
Comment thread App/backend-api/Microsoft.GS.DPS/API/ChatHost/ChatHost.cs
Comment thread App/backend-api/Microsoft.GS.DPS/API/KernelMemory/KernelMemory.cs Outdated
- 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>
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.

2 participants