Skip to content

Fix chatbot error handling: specific error messages and login loop fix#746

Open
PRAteek-singHWY wants to merge 2 commits intoOWASP:mainfrom
PRAteek-singHWY:fix-chatbot-error-handling-v2
Open

Fix chatbot error handling: specific error messages and login loop fix#746
PRAteek-singHWY wants to merge 2 commits intoOWASP:mainfrom
PRAteek-singHWY:fix-chatbot-error-handling-v2

Conversation

@PRAteek-singHWY
Copy link
Contributor

This PR addresses Issue #692 by improving the error handling logic in the Chatbot component. It replaces generic error messages with specific feedback from the server and fixes a potential infinite loop in the authentication check.

Changes Overview

Feature Before After Benefit
User Feedback Generic error: "Document could not be loaded" Specific Error: Displays the actual error message from the server (e.g., "Network Error", "Rate limit exceeded"). Users know exactly why the request failed and what to do next.
Error Logic Ignored HTTP error codes (400/500) and failed silently on JSON parsing. Robust Parsing: Checks !response.ok, parses JSON or text errors, and throws meaningful exceptions. Prevents silent failures and catches server-side validation issues.
Stability login() called directly in render body. Fixed: login() called inside useEffect. Prevents potential infinite re-render loops and improves app performance.
Code Cleanup Unused import LoadingAndErrorIndicator present. Cleaned: Removed unused import. Cleaner codebase.

How to Test

  1. Network Error: Disconnect internet or block the network request in DevTools. Verify the UI says "Network error..." instead of a generic message.
  2. Server Error: If possible, trigger a 500 or 400 error from the backend. Verify the UI displays the specific message returned by the API.
  3. Normal Usage: Verify that chatting works normally when no errors occur.

fixes #692

@PRAteek-singHWY PRAteek-singHWY force-pushed the fix-chatbot-error-handling-v2 branch from d338919 to f153cda Compare February 16, 2026 14:09
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.

Inconsistent Error Handling in Chatbot

1 participant