[monorepo] prepare for zod everywhere epic (#36027)

GitOrigin-RevId: f082ae7fc7857fa72b2c1823645050bd4f6df305
This commit is contained in:
Jakob Ackermann
2026-09-17 11:42:46 +00:00
committed by Copybot
parent bff27fc3cc
commit 81df324bcc
27 changed files with 2588 additions and 70 deletions
+1
View File
@@ -153,6 +153,7 @@ class RequestFailedError extends OError {
url,
method: opts.method ?? 'GET',
status: response.status,
...([400, 409, 413, 422].includes(response.status) ? { body } : {}),
})
this.response = response
@@ -305,6 +305,34 @@ describe('fetch-utils', function () {
})
})
describe('RequestFailedError', function () {
it('includes the response body in OError.info for a 400', async function () {
const err = await getRejection(fetchNothing(url('/400')))
expect(err.info).to.have.property('body', 'boom-400')
})
it('includes the response body in OError.info for a 409', async function () {
const err = await getRejection(fetchNothing(url('/409')))
expect(err.info).to.have.property('body', 'boom-409')
})
it('includes the response body in OError.info for a 413', async function () {
const err = await getRejection(fetchNothing(url('/413')))
expect(err.info).to.have.property('body', 'boom-413')
})
it('includes the response body in OError.info for a 422', async function () {
const err = await getRejection(fetchNothing(url('/422')))
expect(err.info).to.have.property('body', 'boom-422')
})
it('omits the response body from OError.info for a 500', async function () {
const err = await getRejection(fetchNothing(url('/500')))
expect(err.body).to.equal('Internal Server Error')
expect(err.info).to.not.have.property('body')
})
})
describe('fetchString', function () {
it('returns a string', async function () {
const body = await fetchString(url('/hello'))
@@ -509,3 +537,12 @@ async function expectRequestAborted(req) {
}
const wait = ms => new Promise(resolve => setTimeout(resolve, ms))
async function getRejection(promise) {
try {
await promise
} catch (err) {
return err
}
expect.fail('expected promise to reject')
}
@@ -39,6 +39,22 @@ class TestServer {
res.sendStatus(500)
})
this.app.get('/400', (req, res) => {
res.status(400).send('boom-400')
})
this.app.get('/409', (req, res) => {
res.status(409).send('boom-409')
})
this.app.get('/413', (req, res) => {
res.status(413).send('boom-413')
})
this.app.get('/422', (req, res) => {
res.status(422).send('boom-422')
})
this.app.post('/sink', (req, res) => {
req.on('data', () => {})
req.on('end', () => {