SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix(settings): guard against non-APIError in logs retention error state (#11685)
SagarRajput-730f52ecb6d28
diff --git a/frontend/src/container/GeneralSettings/__tests__/index.test.tsx b/frontend/src/container/GeneralSettings/__tests__/index.test.tsxnew file mode 100644index 0000000000..68a2826f5a--- /dev/null+++ b/frontend/src/container/GeneralSettings/__tests__/index.test.tsx@@ -0,0 +1,41 @@+import { useQueries } from 'react-query';+import { render, screen } from 'tests/test-utils';++import GeneralSettings from '../index';++jest.mock('react-query', () => ({+ ...jest.requireActual('react-query'),+ useQueries: jest.fn(),+}));++const baseQueryResult = {+ isError: false,+ isLoading: false,+ isFetching: false,+ isSuccess: true,+ data: undefined,+ error: null,+ refetch: jest.fn(),+};++describe('GeneralSettings index', () => {+ it('renders fallback message when logs query fails with a non-APIError', () => {+ (useQueries as jest.Mock).mockReturnValue([+ { ...baseQueryResult },+ { ...baseQueryResult },+ {+ ...baseQueryResult,+ isError: true,+ isSuccess: false,+ error: new TypeError(+ "Cannot read properties of undefined (reading 'code')",+ ),+ },+ { ...baseQueryResult },+ ]);++ render(<GeneralSettings />);++ expect(screen.getByText('something_went_wrong')).toBeInTheDocument();+ });+});diff --git a/frontend/src/container/GeneralSettings/index.tsx b/frontend/src/container/GeneralSettings/index.tsxindex 001bb13ccd..4682f95947 100644--- a/frontend/src/container/GeneralSettings/index.tsx+++ b/frontend/src/container/GeneralSettings/index.tsx@@ -76,7 +76,9 @@ function GeneralSettings(): JSX.Element {if (getRetentionPeriodLogsApiResponse.isError || getDisksResponse.isError) {return (<Typography>- {(getRetentionPeriodLogsApiResponse.error as APIError).getErrorMessage() ||+ {(getRetentionPeriodLogsApiResponse.error instanceof APIError+ ? getRetentionPeriodLogsApiResponse.error.getErrorMessage()+ : undefined) ||getDisksResponse.data?.error ||t('something_went_wrong')}</Typography>