Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/plugins/google-genai/src/googleai/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ async function makeRequest(
}
return response;
} catch (e: unknown) {
logger.error(e);
logger.debug(e);
if (e instanceof GenkitError) {
throw e;
}
Expand Down
2 changes: 1 addition & 1 deletion js/plugins/google-genai/src/vertexai/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ async function makeRequest(
}
return response;
} catch (e: unknown) {
logger.error(e);
logger.debug(e);
if (e instanceof GenkitError) {
throw e;
}
Expand Down
21 changes: 21 additions & 0 deletions js/plugins/google-genai/tests/googleai/client_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import * as assert from 'assert';
import { logger } from 'genkit/logging';
import { afterEach, beforeEach, describe, it } from 'node:test';
import * as sinon from 'sinon';
import { TextEncoder } from 'util';
Expand Down Expand Up @@ -273,6 +274,26 @@ describe('Google AI Client', () => {
);
});

it('should log failed requests at debug level and not error level before rethrowing', async () => {
const errorStub = sinon.stub(logger, 'error');
const debugStub = sinon.stub(logger, 'debug');
mockFetchResponse(
{ error: { message: 'Too many requests' } },
false,
429,
'Too Many Requests'
);

await assert.rejects(listModels(apiKey), (err: any) => {
assert.strictEqual(err.name, 'GenkitError');
assert.strictEqual(err.status, 'RESOURCE_EXHAUSTED');
return true;
});

sinon.assert.notCalled(errorStub);
sinon.assert.calledOnce(debugStub);
});

it('does not apply Interactions error-code mapping to non-Interactions URLs', async () => {
// `safety` would map to FAILED_PRECONDITION on the Interactions path.
mockFetchResponse(
Expand Down
21 changes: 21 additions & 0 deletions js/plugins/google-genai/tests/vertexai/client_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import * as assert from 'assert';
import { logger } from 'genkit/logging';
import { GoogleAuth } from 'google-auth-library';
import { afterEach, beforeEach, describe, it } from 'node:test';
import * as sinon from 'sinon';
Expand Down Expand Up @@ -1137,6 +1138,26 @@ describe('Vertex AI Client', () => {
return true;
});
});

it('should log failed requests at debug level and not error level before rethrowing', async () => {
const errorStub = sinon.stub(logger, 'error');
const debugStub = sinon.stub(logger, 'debug');
mockFetchResponse(
{ error: { message: 'Too many requests' } },
false,
429,
'Too Many Requests'
);

await assert.rejects(listModels(regionalClientOptions), (err: any) => {
assert.strictEqual(err.name, 'GenkitError');
assert.strictEqual(err.status, 'RESOURCE_EXHAUSTED');
return true;
});

sinon.assert.notCalled(errorStub);
sinon.assert.calledOnce(debugStub);
});
});

describe('generateContentStream full aggregation tests', () => {
Expand Down
Loading