fix: improve error handling — stop silently swallowing errors across backend and frontend#1
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Conversation
- Replace silent `if (!userId) return` with proper 401 JSON responses in user, issue, and repo controllers - Fix middleware silent `if(!secret) return` to send 500 responses instead of hanging the request - Make blacklistToken propagate errors (throw) instead of swallowing - Await blacklistToken calls in auth/user controllers - Make logoutUser handler async to support await - Fix deleteRepository re-throwing unhandled error (now returns 500) - Fix unstarRepository missing return after early response - Add userId null checks to getMyRepositories/getMyStarredRepos - Add try/catch and env var validation to copyRepoFilesInS3 - Fix CLI commands to set process.exitCode on failure instead of silently swallowing errors - Frontend useAuth: expose error state with API error message extraction - Frontend useUser: expose error state for consuming components Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Summary
Multiple request handlers silently dropped errors by returning without sending an HTTP response (e.g.
if (!userId) return;), leaving the client hanging with no feedback. This PR systematically fixes those patterns and several other error-handling gaps.Backend — silent
return→ proper HTTP responses:9 controller handlers (
updateUserProfile,deleteUserProfile,getMyFollowers,getMyFollowing,createIssue,updateIssue,deleteIssue,getMyIssues,updateMyIssuesById) had bareif (!userId) return;guards that silently hung the request. Now return401 Unauthorized.getMyRepositoriesandgetMyStarredReposdidn't checkuserIdat all before using it as a Prismawhereclause — added the same 401 guard.Backend — middleware:
isAuthenticatedandoptionalAuthhadif(!secret) return;whenJWT_SECRETwas missing — silently hung every request. Now returns500with a logged config error.Backend — error propagation:
blacklistTokenswallowed Redis failures → nowthrows so callers (logout, refresh, delete-user) surface the error. Callers nowawaitit;logoutUsermadeasync.deleteRepositorycaught Prisma P2025 butthrow error'd everything else with no handler → now returns500.unstarRepositorywas missingreturnbefore sending "You haven't starred this repo" → execution continued and tried to disconnect anyway.copyRepoFilesInS3had no error handling + noS3_BUCKETenv check → added try/catch and throws on failure so the fork flow surfaces errors.CLI commands:
init,addRepo,commitRepo,pushRepo,pullRepo,revertRepoall swallowed errors withconsole.logand exited 0 → now setprocess.exitCode = 1.Frontend hooks:
useAuth: Addederrorstate that extracts the API error message (viaaxios.isAxiosError) instead ofconsole.log("Client side error"). Consumers can now display "wrong password", "User already exists", etc.useUser: Addederrorstate (returned alongsideuserandloading) so components can render error UI instead of silently showing nothing.Link to Devin session: https://app.devin.ai/sessions/73fafa714985405a9af113768ba0d919
Requested by: @amnkarn