Skip to content

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.

feat: filter fields with no name in field selector (#12512)

Aditya Singh52dd57074e0a
diff --git a/frontend/src/container/OptionsMenu/__test__/useOptionsMenu.test.ts b/frontend/src/container/OptionsMenu/__test__/useOptionsMenu.test.ts
index aa4d854692..8d1650312b 100644
--- a/frontend/src/container/OptionsMenu/__test__/useOptionsMenu.test.ts
+++ b/frontend/src/container/OptionsMenu/__test__/useOptionsMenu.test.ts
@@ -387,4 +387,42 @@ describe('useOptionsMenu', () => {
expect(remaining).toHaveLength(seedColumns.length);
});
});
+
+ describe('fieldsSelector.value drops legacy columns without a name', () => {
+ it('excludes entries missing name while keeping valid columns', () => {
+ (useGetQueryKeySuggestions as jest.Mock).mockReturnValue({
+ data: { data: { data: { keys: {} } } },
+ isFetching: false,
+ });
+ (usePreferenceContext as jest.Mock).mockReturnValue({
+ traces: {
+ preferences: {
+ columns: [
+ { name: 'body', fieldContext: 'log' },
+ { key: 'legacy-key-no-name', fieldContext: 'log' },
+ { name: 'timestamp', fieldContext: 'log' },
+ ],
+ formatting: { format: 'table', maxLines: 1, fontSize: 'small' },
+ },
+ updateColumns: mockUpdateColumns,
+ updateFormatting: mockUpdateFormatting,
+ },
+ logs: {
+ preferences: { columns: [], formatting: {} },
+ updateColumns: mockUpdateColumns,
+ updateFormatting: mockUpdateFormatting,
+ },
+ });
+
+ const { result } = renderHook(() =>
+ useOptionsMenu({
+ dataSource: DataSource.TRACES,
+ aggregateOperator: 'count',
+ }),
+ );
+
+ const fields = result.current.config.fieldsSelector?.value ?? [];
+ expect(fields.map((f) => f.name)).toStrictEqual(['body', 'timestamp']);
+ });
+ });
});
diff --git a/frontend/src/container/OptionsMenu/useOptionsMenu.ts b/frontend/src/container/OptionsMenu/useOptionsMenu.ts
index 45b668650a..6d7c22464d 100644
--- a/frontend/src/container/OptionsMenu/useOptionsMenu.ts
+++ b/frontend/src/container/OptionsMenu/useOptionsMenu.ts
@@ -399,7 +399,7 @@ const useOptionsMenu = ({
onReorder: reorderSelectColumns,
},
fieldsSelector: {
- value: preferences?.columns ?? [],
+ value: preferences?.columns?.filter((item) => has(item, 'name')) ?? [],
onFieldsChange: updateColumns,
},
format: {