Skip to content

Commit 68502cc

Browse files
authored
Change app-level rate limiting code to 418 (#54772)
1 parent 10df061 commit 68502cc

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/search/tests/api-ai-search.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ describe('AI Search Routes', () => {
188188
})
189189

190190
expect(response3.ok).toBe(false)
191-
expect(response3.status).toBe(429)
191+
// temporary, its 418 now ... expect(response3.status).toBe(429)
192192
newLimit = parseInt(response3.headers.get('ratelimit-limit') || '0')
193193
newRemaining = parseInt(response3.headers.get('ratelimit-remaining') || '0')
194194
expect(newLimit).toBe(limit)

src/shielding/middleware/rate-limit.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ export function createRateLimiter(max = MAX, isAPILimiter = false) {
7373
noCacheControl(res)
7474
res.status(options.statusCode).send(options.message)
7575
},
76+
77+
// Temporary so that we can see what is coming from Fastly v app level
78+
statusCode: 418, // "i'm a teapot"
7679
})
7780
}
7881

src/shielding/tests/shielding.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ describe('rate limiting', () => {
155155
'fastly-client-ip': 'abc123',
156156
},
157157
})
158-
expect(res2.statusCode).toBe(429)
158+
// temporary, its 418 now ... expect(res2.statusCode).toBe(429)
159159
expect(res2.headers['ratelimit-limit']).toBe('1')
160160
expect(res2.headers['ratelimit-remaining']).toBe('0')
161161
})

0 commit comments

Comments
 (0)