Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Add fallback logic for index type detection #476

Merged
merged 2 commits into from
Mar 4, 2025
Merged
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
6 changes: 3 additions & 3 deletions server/routes/index_type_detect.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ describe('detectIndexType', () => {
(getIndexCache as jest.Mock).mockReturnValue(null);
mockClient.request.mockRejectedValue(new Error('Search failed'));

await expect(
detectIndexType(mockClient, mockAssistantClient, 'test-index', 'test-source')
).rejects.toThrow('Search failed');
const result = await detectIndexType(mockClient, mockAssistantClient, 'test-index', undefined);

expect(result).toBe(false);
});

it('should handle undefined dataSourceId', async () => {
Expand Down
6 changes: 4 additions & 2 deletions server/routes/index_type_detect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function detectIndexType(
assistantClient: AssistantClient,
indexName: string,
dataSourceId: string | undefined
) {
): Promise<boolean> {
const indexCache = getIndexCache(indexName, dataSourceId ? dataSourceId : '');
if (indexCache) {
return indexCache.isLogRelated;
Expand Down Expand Up @@ -84,6 +84,8 @@ export async function detectIndexType(
}
return false;
} catch (error) {
throw error;
console.error('Error detecting index type:', error);
// Can not detect index type and return default as is not log related
return false;
}
}
Loading