Compare commits

...

1 Commits

Author SHA1 Message Date
Abhi Kumar
0951a98fcb fix(query-builder): stop the panel-type field list growing on every change
`updateSuperSetQueryBuilderData` appended `dataSource` to the field list with
`propsRequired?.push('dataSource')`. That list is the array held in
`panelTypeDataSourceFormValuesMap`, so the module-level table grew by one entry on
every query-builder change, unbounded for the life of the page. It was harmless only
because the assignment it drives is idempotent. The field now travels on a copy.

The guard stays an `if` rather than defaulting to an empty list: the previous
optional chaining meant a panel type outside the builder set copied nothing at all,
`dataSource` included.

Two neighbours in the same area, both no-ops:

- `PANEL_TYPES_INITIAL_QUERY` had exactly one reference in the repo — its own
  definition.
- `PanelTypeKeys` was a hand-written union of the enum's key names that had fallen
  three behind (`BAR`, `PIE`, `HISTOGRAM`), so it is derived now. Nothing relied on
  the omission: `useChartMutable` builds its key array from `Object.keys` through an
  untyped `[].slice.call`, so all nine were already there at runtime.

Assisted-by: Claude Opus 5
2026-09-07 15:53:43 +05:30
3 changed files with 14 additions and 23 deletions

View File

@@ -601,18 +601,6 @@ export const listViewInitialLogQuery: Query = {
},
};
export const PANEL_TYPES_INITIAL_QUERY: Record<PANEL_TYPES, Query> = {
[PANEL_TYPES.TIME_SERIES]: initialQueriesMap.metrics,
[PANEL_TYPES.VALUE]: initialQueriesMap.metrics,
[PANEL_TYPES.TABLE]: initialQueriesMap.metrics,
[PANEL_TYPES.LIST]: listViewInitialLogQuery,
[PANEL_TYPES.TRACE]: initialQueriesMap.traces,
[PANEL_TYPES.BAR]: initialQueriesMap.metrics,
[PANEL_TYPES.PIE]: initialQueriesMap.metrics,
[PANEL_TYPES.HISTOGRAM]: initialQueriesMap.metrics,
[PANEL_TYPES.EMPTY_WIDGET]: initialQueriesMap.metrics,
};
export const listViewInitialTraceQuery: Query = {
// it should be the above commented query
...initialQueriesMap.traces,

View File

@@ -766,10 +766,15 @@ export function QueryBuilderProvider({
queryItem.dataSource
].builder.queryData;
propsRequired?.push('dataSource');
propsRequired?.forEach((p: any) => {
set(queryItem, p, get(newQueryItem, p));
});
// `dataSource` travels with the panel type's fields, but is appended to a
// copy: `propsRequired` is the list held in
// `panelTypeDataSourceFormValuesMap`, and pushing onto it grew that
// module-level array by one entry on every call.
if (propsRequired) {
[...propsRequired, 'dataSource'].forEach((p: any) => {
set(queryItem, p, get(newQueryItem, p));
});
}
return queryItem;
}

View File

@@ -211,13 +211,11 @@ export enum QueryFunctionsTypes {
FILL_ZERO = 'fillZero',
}
export type PanelTypeKeys =
| 'TIME_SERIES'
| 'VALUE'
| 'TABLE'
| 'LIST'
| 'TRACE'
| 'EMPTY_WIDGET';
/**
* Key names of {@link PANEL_TYPES}. Derived rather than listed: the hand-written
* version had fallen behind the enum by three members (`BAR`, `PIE`, `HISTOGRAM`).
*/
export type PanelTypeKeys = keyof typeof PANEL_TYPES;
export enum ReduceOperators {
LAST = 'last',