fix(coding): reject mismatched Data Service errors
This commit is contained in:
@@ -202,6 +202,24 @@ describe('DataServiceCloudClient', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('rejects a known error code paired with the wrong HTTP status', async () => {
|
||||
const client = new DataServiceCloudClient({
|
||||
fetchImpl: vi.fn<typeof fetch>().mockResolvedValue(
|
||||
jsonResponse({ detail: { code: 'quota_exceeded' } }, { status: 400 }),
|
||||
),
|
||||
getAccessToken: vi.fn().mockResolvedValue('access-token'),
|
||||
});
|
||||
|
||||
const result = await client.inspect(projectId);
|
||||
|
||||
expect(result).toMatchObject({
|
||||
success: false,
|
||||
status: 502,
|
||||
code: 'upstream_invalid_response',
|
||||
data: null,
|
||||
});
|
||||
});
|
||||
|
||||
it('normalizes malformed client errors and all upstream 5xx responses safely', async () => {
|
||||
const fetchImpl = vi.fn<typeof fetch>()
|
||||
.mockResolvedValueOnce(new Response(null, { status: 404 }))
|
||||
|
||||
Reference in New Issue
Block a user