fix(backend): restore server boot - resolve six independent crashes - #1010
Open
Rudra-clrscr wants to merge 1 commit into
Open
fix(backend): restore server boot - resolve six independent crashes#1010Rudra-clrscr wants to merge 1 commit into
Rudra-clrscr wants to merge 1 commit into
Conversation
upstream/main currently cannot boot at all; each require-time crash
was masking the next one, so this required working through them one
at a time until `node server.js` actually reaches "Server running".
- middleware/rateLimiter.js: a stray function-body fragment
(res.setHeader/next() referencing undefined res/remaining/next) sat
at module top level, crashing on require(). Confirmed dead via `git
log -S`: it was accidentally committed whole-cloth in "feat: Add API
rate limit dashboard", whose actual data source is the separate,
self-contained GET /api/v1/analytics/rate-limit route - nothing
references these lines. Deleted them.
- middleware/poisoningGuard.js: trainingRateLimiter's keyGenerator
returned a raw IP without express-rate-limit's ipKeyGenerator()
helper, which v7 rejects at startup (ERR_ERL_KEY_GEN_IPV6). Fixed
to match the pattern already used everywhere else in
middleware/rateLimiter.js.
- backend/routes/feedbackRoutes.js: required '../middleware/auth' and
'../models/Feedback', neither of which exist - the real paths are
'../middleware/authMiddleware' (used by every other route file) and
'../models/UserFeedback' (the only feedback model in the repo).
- backend/controllers/bulkPredictController.js requires
'../services/bulkPredictService', which was never committed. Added
it: batches rows through the same ML API /predict call and
circuit-breaker/fallback pattern predictionRoutes.js already uses
for single predictions, isolating per-row failures instead of
aborting the whole upload.
- backend/routes/authRoutes.js was 1529 lines of duplicated dead
logic (generateToken, buildAuthResponse, register, login, etc. each
declared twice) with zero actual router.* registrations - /api/auth
has been completely non-functional. authController.js already has
full, correct implementations of everything this router needs;
replaced the file with the router that actually wires them up
(verified this exact rewrite already exists, reviewed, and pushed
on the fix/backend-eslint-errors branch). That router depends on
backend/validators/auth.validator.js, which upstream deleted at
some point after that branch forked - recreated it with validation
rules mirrored from models/User.js's own schema constraints
(username 3-30 chars/alphanumeric+underscore, valid email, password
min 6 chars).
- backend/utils/utils/emailTransporter.js (double-nested by mistake -
the file's own header comment says `backend/utils/emailTransporter.js`)
moved to the path authController.js already expects it at.
- backend/routes/analyticsRoutes.js required a '../models/Prediction'
that doesn't exist, used only by ~85 lines of legacy /trends and
/analytics handlers sitting *after* the file's module.exports -
dead weight superseded by the analyticsController-based routes
registered earlier in the same file (confirmed neither shadowed
path is called by the frontend). The one route in that dead block
the frontend actually calls, GET /accuracy, had a straight copy-paste
of the rate-limit-dashboard body (down to an undefined `cache`
reference) instead of computing accuracy at all; reimplemented it
against UserFeedback (predicted_label vs. correct_label) to match
the {accuracy, total, correct, incorrect} shape AccuracyMeter.jsx
actually reads.
Verified by booting the full server with dummy env vars end-to-end:
reaches "Server running on http://localhost:3000" and stays up
(Redis/MongoDB connection failures are handled by existing fallback
logic, not fatal). Confirmed routing/middleware wiring via curl:
GET /health -> 200; POST /api/auth/register and /login -> 400 on an
empty body (validators/auth.validator.js firing correctly, not a
crash or 404); POST /api/feedback, GET /api/v1/analytics/{summary,accuracy},
GET /api/poisoning/status -> 401 (protect middleware reached and
enforced, routes are live); GET /this-route-does-not-exist -> 404
control. `node --check` and `eslint` clean on every touched file (no
new errors; pre-existing warnings/errors elsewhere confirmed via
diffing against unmodified upstream/main).
|
Someone is attempting to deploy a commit to the Aditya Sharma's projects Team on Vercel. A member of the Team first needs to authorize it. |
Userunknown84
requested changes
Jul 29, 2026
Userunknown84
left a comment
Owner
There was a problem hiding this comment.
AuthRoutes.js check karo kafi code remove ho raha h .That code is need.
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.
Problem
upstream/maincurrently cannot boot at all. Each require-time crash wasmasking the next one, so fixing this required working through six separate,
unrelated bugs one at a time until
node server.jsactually reached"Server running".
What's fixed
middleware/rateLimiter.js— an orphaned function-body fragment(
res.setHeader(...),next()) sat at module top level, referencingres/remaining/nextthat don't exist there, crashing onrequire().Traced via
git log -Sto the "Add API rate limit dashboard" commit —that feature's real data source is the separate
GET /api/v1/analytics/rate-limitroute, so this fragment was dead on arrival. Deleted.
middleware/poisoningGuard.js—trainingRateLimiter'skeyGeneratorreturned a raw IP without express-rate-limit v7's required
ipKeyGenerator()wrapper (ERR_ERL_KEY_GEN_IPV6). Fixed to match thepattern already used everywhere else in
rateLimiter.js.routes/feedbackRoutes.js— required../middleware/authand../models/Feedback, neither of which exist. Fixed to../middleware/authMiddlewareand../models/UserFeedback.services/bulkPredictService.js— required bybulkPredictController.jsbut never committed. Added it, reusing theexisting ML-API circuit-breaker/fallback pattern from
predictionRoutes.jsfor per-row resilience on bulk uploads.routes/authRoutes.js— 1529 lines of duplicated dead logic(
generateToken,buildAuthResponse,register,logineach declaredtwice) with zero actual
router.*registrations —/api/authhasbeen completely non-functional. Replaced with a clean router delegating
to
authController.js(which already has full, correct implementationsof everything needed). That router depends on
backend/validators/auth.validator.js, deleted from upstream at somepoint — recreated it with rules mirrored from
models/User.js's ownschema constraints.
utils/utils/emailTransporter.js— nested one directory too deep bymistake (the file's own header comment confirms the intended path).
Moved to
utils/emailTransporter.js.routes/analyticsRoutes.js— required a nonexistent../models/Predictionfrom ~85 lines of dead code sitting after the file's own
module.exports, superseded by the controller-based routes registeredearlier in the same file. The one route in that dead block the frontend
actually calls,
GET /accuracy, had a straight copy-paste of unrelatedrate-limit-dashboard logic (down to an undefined
cachereference)instead of computing accuracy. Reimplemented against
UserFeedback(
predicted_labelvscorrect_label) to match the shapeAccuracyMeter.jsxactually reads.Verification
🚀 Server running on http://localhost:3000and stays up (Redis/MongoDBconnection failures are handled by existing fallback logic, not fatal).
curl, not justnode --check:GET /health→ 200POST /api/auth/register//loginwith an empty body → 400(validators firing correctly — not a crash, not a 404)
POST /api/feedback,GET /api/v1/analytics/{summary,accuracy},GET /api/poisoning/status→ 401 (protect middleware reached andenforced — routes are live)
GET /this-route-does-not-exist→ 404 controlnode --checkandeslintclean on every touched file — confirmed nonew errors by diffing lint output against unmodified
upstream/main./api/poisoning/*endpoints crash —llm_poisoning_defense.pyreferenced by the router does not exist #1000-[Bug]: Domain reputation DNSBL lookups query the raw domain name against IP-based blocklists, socheckReputation()almost never flags anything #1003) in a scratchworktree and re-verified the combined tree boots and routes correctly —
no file overlap, no conflicts.
Recommend merging this first — none of #1000-#1003's endpoints are
reachable in production until the server can actually boot.