Skip to content
Open
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
8 changes: 4 additions & 4 deletions sec-gemini-ts/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ export class InteractiveSession {
} = options;

// --- Validation ---
if (ttl <= MIN_TTL_SECONDS) {
throw new Error(`TTL must be greater than ${MIN_TTL_SECONDS} seconds.`);
if (ttl < MIN_TTL_SECONDS) {
throw new Error(`TTL must be at least ${MIN_TTL_SECONDS} seconds.`);
}
if (!model || !model.model_string) {
throw new Error('Valid ModelInfoInput object is required for registration.');
Expand Down Expand Up @@ -499,8 +499,8 @@ export class InteractiveSession {

// Apply TTL update logic
if (ttl > 0) {
if (ttl <= MIN_TTL_SECONDS) {
throw new Error(`TTL must be greater than ${MIN_TTL_SECONDS} seconds`);
if (ttl < MIN_TTL_SECONDS) {
throw new Error(`TTL must be at least ${MIN_TTL_SECONDS} seconds`);
}
updatePayload.ttl = ttl;
}
Expand Down
14 changes: 14 additions & 0 deletions sec-gemini-ts/tests/session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,20 @@ describe('Session', () => {
jest.clearAllTimers();
openedUrl = '';
});
test('should throw error when TTL is below minimum', async () => {
const registerPromise = session.register({
ttl: 299,
model: model,
});
await expect(registerPromise).rejects.toThrow('TTL must be at least 300 seconds.');
});
test('should register session when TTL is exactly 300', async () => {
const registerPromise = session.register({
ttl: 300,
model: model,
});
await expect(registerPromise).resolves.not.toThrow();
});
test('should throw error when registering session', async () => {
// Throw error during post request to register session.
registerSession.mockImplementationOnce(() => {
Expand Down