Merge pull request #33490 from overleaf/em-parse-req-errors-2

Reintroduce custom error types in request validation

GitOrigin-RevId: 1985ca04c8fe693fb836b042517d94700343bc46
This commit is contained in:
Eric Mc Sween
2026-05-07 13:32:29 -04:00
committed by Copybot
parent 8c0589df7f
commit 2bb35fafb8
17 changed files with 105 additions and 85 deletions

View File

@@ -13,8 +13,10 @@ import methodOverride from 'method-override'
import { mongoClient } from './app/js/mongodb.js'
import NotificationsController from './app/js/NotificationsController.ts'
import HealthCheckController from './app/js/HealthCheckController.ts'
import { isZodErrorLike } from 'zod-validation-error'
import { ParamsError } from '@overleaf/validation-tools'
import {
InvalidParamsError,
InvalidRequestError,
} from '@overleaf/validation-tools'
const app = express()
@@ -56,10 +58,10 @@ const handleApiError: ErrorRequestHandler = (
next: NextFunction
) => {
req.logger.addFields({ err })
if (err instanceof ParamsError) {
if (err instanceof InvalidParamsError) {
req.logger.setLevel('warn')
res.sendStatus(404)
} else if (isZodErrorLike(err)) {
} else if (err instanceof InvalidRequestError) {
req.logger.setLevel('warn')
res.sendStatus(400)
} else {