You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it('strips HTML tags from 502 Bad Gateway response',()=>{
399
+
consthtmlBody='<html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body>\r\n<center><h1>502 Bad Gateway</h1></center>\r\n<hr><center>nginx</center>\r\n</body>\r\n</html>\r\n';
400
+
consterr=classifyApiError(502,htmlBody);
401
+
expect(err.code).toBe('server_error');
402
+
expect(err.message).not.toContain('<html>');
403
+
expect(err.message).not.toContain('<head>');
404
+
expect(err.message).not.toContain('</h1>');
405
+
expect(err.message).toContain('502 Bad Gateway');
406
+
});
407
+
408
+
it('strips HTML from 503 Service Unavailable response',()=>{
409
+
consthtmlBody='<html><body><h1>503 Service Temporarily Unavailable</h1></body></html>';
410
+
consterr=classifyApiError(503,htmlBody);
411
+
expect(err.message).not.toContain('<html>');
412
+
expect(err.message).toContain('503 Service Temporarily Unavailable');
413
+
});
414
+
415
+
it('preserves JSON error bodies as-is',()=>{
416
+
constjsonBody='{"error":"model requires more system memory (9.9 GiB) than is available (3.7 GiB)"}';
417
+
consterr=classifyApiError(500,jsonBody);
418
+
expect(err.message).toContain('model requires more system memory');
419
+
});
420
+
421
+
it('preserves plain text error bodies as-is',()=>{
422
+
consttextBody='Rate limit exceeded for model gpt-4o';
423
+
consterr=classifyApiError(429,textBody);
424
+
expect(err.message).toContain('Rate limit exceeded for model gpt-4o');
425
+
});
426
+
427
+
it('preserves rawDetail with original HTML for debugging',()=>{
428
+
consthtmlBody='<html><body>502 Bad Gateway</body></html>';
429
+
consterr=classifyApiError(502,htmlBody);
430
+
// rawDetail should still have the original for debugging
0 commit comments