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-08 08:10:13 +00:00
committed by Copybot
parent 8c0589df7f
commit 2bb35fafb8
17 changed files with 105 additions and 85 deletions
@@ -845,8 +845,8 @@ describe('CompileController', function () {
it('should reject the request', function (ctx) {
ctx.next.should.have.been.calledWithMatch({
name: 'ParamsError',
cause: asZodError({
name: 'InvalidParamsError',
zodError: asZodError({
code: 'custom',
path: ['params', 'file'],
message: 'path traversal detected',
@@ -868,8 +868,8 @@ describe('CompileController', function () {
it('should reject the request', function (ctx) {
ctx.next.should.have.been.calledWithMatch({
name: 'ParamsError',
cause: asZodError({
name: 'InvalidParamsError',
zodError: asZodError({
origin: 'string',
code: 'invalid_format',
format: 'regex',
@@ -695,7 +695,7 @@ describe('SubscriptionController', function () {
ctx.next = sinon.stub()
await expect(
ctx.SubscriptionController.pauseSubscription(ctx.req, ctx.res, ctx.next)
).to.be.rejectedWith('Invalid params')
).to.be.rejectedWith('Invalid request parameters')
})
it('should throw an error if an invalid pause length is provided', async function (ctx) {
@@ -1,6 +1,6 @@
import { assert, beforeEach, describe, it, vi } from 'vitest'
import sinon from 'sinon'
import { ZodError } from 'zod'
import { InvalidRequestError } from '@overleaf/validation-tools'
const modulePath = '../../../../app/src/Features/Tags/TagsController.mjs'
@@ -202,7 +202,7 @@ describe('TagsController', function () {
it('without a name', function (ctx) {
ctx.req.body = { name: undefined }
ctx.TagsController.renameTag(ctx.req, ctx.res).should.be.rejectedWith(
ZodError
InvalidRequestError
)
})
})