-
Notifications
You must be signed in to change notification settings - Fork 38
Description
Problem
The UI allows users to input arbitrary code or snippets for explanation by the AI backend.
There doesn’t seem to be frontend validation or sanitization of the code input before sending it to the backend.
If a user submits an extremely large input (too many lines, huge file size) or malicious strings (e.g., code with embedded scripts, or extremely long single lines meant to break parsers or UIs), there may be performance issues, or risk of denial-of-service, crashes, or UI freezes.
And if the backend responds with an error, it's unclear how gracefully that is handled by the frontend. Users might see unhelpful or broken UI, or infinite loading spinners.
Why it matters
Improves robustness and security: malicious or malformed input should not crash the UI or backend, or degrade user experience.
Enhances user experience: users get clear feedback (“your input is too large,” “please submit shorter snippets,” “syntax error detected,” etc.) rather than vague failures or no response.
It shows you care about quality and safe coding practices — a good signal in an open-source contribution.
Proposed Solution
Add client-side validation:
Limit the maximum input size (e.g. max lines, max characters).
Warn users or block submission when limits are exceeded.
Optionally detect obviously malformed input (e.g. extremely long single line, suspicious characters or non-text blobs) and prompt the user to clean it up.
Add a timeout or cancellation mechanism:
If the AI explanation takes too long or backend is unresponsive, allow the frontend to abort the request and show a timeout message.
Graceful error handling:
Catch API/backend errors or unexpected responses.
Display user-friendly error messages: “Oops, something went wrong. Please try again later, or reduce the input size,” rather than a broken UI or silent failure.
Optional enhancement: show a “loading” or “processing” indicator with a cancel button, so users aren’t stuck staring at a spinner with no control.