Fix Google Doc error message being treated as quiz input#576
Fix Google Doc error message being treated as quiz input#576Adilkhan6465 wants to merge 2 commits intoAOSSIE-Org:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe Text_Input component adds an Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
eduaid_web/src/pages/Text_Input.jsx (2)
179-179: Consider clearing error state when user types.When the user starts typing new content after an error, the
inputErrormessage remains visible. Clearing it on input change would provide better UX feedback.Proposed enhancement
- onChange={(e) => setText(e.target.value)} + onChange={(e) => { + setText(e.target.value); + if (inputError) setInputError(""); + }}Similarly for the URL input at line 209:
- onChange={(e) => setDocUrl(e.target.value)} + onChange={(e) => { + setDocUrl(e.target.value); + if (inputError) setInputError(""); + }}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@eduaid_web/src/pages/Text_Input.jsx` at line 179, The input change handlers should also clear the error state so the error message disappears as the user types; update the onChange for the text input (where setText is called) to also call the state setter that clears inputError (e.g., setInputError('') or setInputError(null)), and do the same for the URL input's onChange (where setUrl is called) so both handlers reset the inputError state when invoked.
35-38: File upload errors still exhibit the same bug pattern.The PR correctly fixes Google Doc error handling, but file upload errors (lines 35 and 38) still use
setText()for error messages. This means if a file upload fails, "Error uploading file" will still be stored intextand could be sent as quiz input.For consistency, consider applying the same fix here.
Proposed fix
try { const data = await apiClient.postFormData("/upload", formData); - setText(data.content || data.error); + if (data.content) { + setText(data.content); + setInputError(""); + } else { + setInputError(data.error || "Error uploading file"); + } } catch (error) { console.error("Error uploading file:", error); - setText("Error uploading file"); + setInputError("Error uploading file"); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@eduaid_web/src/pages/Text_Input.jsx` around lines 35 - 38, The catch block in the file upload flow currently writes the literal error message into the main text state by calling setText("Error uploading file") (inside the try/catch where setText(data.content || data.error) is used); change this to avoid polluting the quiz input: remove the setText call in the catch and instead set a dedicated error state (e.g., setUploadError or setErrorMessage — create it if missing) and/or keep text unchanged, while still logging the error with console.error; update the catch to use the same error-handling pattern used for Google Doc errors so only an error state is updated and text is not overwritten on failures.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@eduaid_web/src/pages/Text_Input.jsx`:
- Around line 59-63: The try/catch currently sets a fallback error string into
the text state (setText(data || "Error in retrieving")) which mixes error
messages into content; update the logic around setText and setInputError so that
setText only receives actual content (e.g., setText(data ?? "")) and preserve
error signalling via setInputError when data is falsy or in the catch block;
locate and change the call to setText in the same block that uses setInputError
so the UI shows an empty/previous content instead of embedding the error string.
---
Nitpick comments:
In `@eduaid_web/src/pages/Text_Input.jsx`:
- Line 179: The input change handlers should also clear the error state so the
error message disappears as the user types; update the onChange for the text
input (where setText is called) to also call the state setter that clears
inputError (e.g., setInputError('') or setInputError(null)), and do the same for
the URL input's onChange (where setUrl is called) so both handlers reset the
inputError state when invoked.
- Around line 35-38: The catch block in the file upload flow currently writes
the literal error message into the main text state by calling setText("Error
uploading file") (inside the try/catch where setText(data.content || data.error)
is used); change this to avoid polluting the quiz input: remove the setText call
in the catch and instead set a dedicated error state (e.g., setUploadError or
setErrorMessage — create it if missing) and/or keep text unchanged, while still
logging the error with console.error; update the catch to use the same
error-handling pattern used for Google Doc errors so only an error state is
updated and text is not overwritten on failures.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 968e3958-e5ea-4dcd-9c54-236ab338b734
📒 Files selected for processing (1)
eduaid_web/src/pages/Text_Input.jsx
|
Closing this PR as the changes have been consolidated into a single unified PR that includes:
Please refer to PR #609 for the complete implementation. |
Addressed Issues:
Fixes #575
Problem
When a user enters an invalid Google Doc URL, the API request fails and the error message "Error retrieving Google Doc content" is stored in the
textstate.If the user clicks Next afterwards, this error message is treated as valid input and sent to the backend to generate a quiz.
Fix
inputErrorstate for handling errors.textstate.Result
Screen Recording
google-doc-bug-fix.mp4.mp4
Additional Notes:
AI Usage Disclosure:
We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.
Check one of the checkboxes below:
I have used the following AI models and tools: TODO
Checklist
Summary by CodeRabbit