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.

chore: dynamic variables first load (#10316)

Ashwin Bhatkal8a4544cbacff
diff --git a/frontend/src/providers/Dashboard/store/dashboardVariables/__tests__/dashboardVariablesStore.test.ts b/frontend/src/providers/Dashboard/store/dashboardVariables/__tests__/dashboardVariablesStore.test.ts
index 2ab39ce7c5..47d540b758 100644
--- a/frontend/src/providers/Dashboard/store/dashboardVariables/__tests__/dashboardVariablesStore.test.ts
+++ b/frontend/src/providers/Dashboard/store/dashboardVariables/__tests__/dashboardVariablesStore.test.ts
@@ -204,6 +204,78 @@ describe('dashboardVariablesStore', () => {
expect(doAllVariablesHaveValuesSelected).toBe(true);
});
+ it('should treat DYNAMIC variable with allSelected=true and selectedValue=undefined as having a value', () => {
+ setDashboardVariablesStore({
+ dashboardId: 'dash-1',
+ variables: {
+ dyn1: createVariable({
+ name: 'dyn1',
+ type: 'DYNAMIC',
+ order: 0,
+ selectedValue: undefined,
+ allSelected: true,
+ }),
+ env: createVariable({
+ name: 'env',
+ type: 'QUERY',
+ order: 1,
+ selectedValue: 'prod',
+ }),
+ },
+ });
+
+ const { doAllVariablesHaveValuesSelected } = getVariableDependencyContext();
+ expect(doAllVariablesHaveValuesSelected).toBe(true);
+ });
+
+ it('should treat DYNAMIC variable with allSelected=true and empty string selectedValue as having a value', () => {
+ setDashboardVariablesStore({
+ dashboardId: 'dash-1',
+ variables: {
+ dyn1: createVariable({
+ name: 'dyn1',
+ type: 'DYNAMIC',
+ order: 0,
+ selectedValue: '',
+ allSelected: true,
+ }),
+ env: createVariable({
+ name: 'env',
+ type: 'QUERY',
+ order: 1,
+ selectedValue: 'prod',
+ }),
+ },
+ });
+
+ const { doAllVariablesHaveValuesSelected } = getVariableDependencyContext();
+ expect(doAllVariablesHaveValuesSelected).toBe(true);
+ });
+
+ it('should treat DYNAMIC variable with allSelected=true and empty array selectedValue as having a value', () => {
+ setDashboardVariablesStore({
+ dashboardId: 'dash-1',
+ variables: {
+ dyn1: createVariable({
+ name: 'dyn1',
+ type: 'DYNAMIC',
+ order: 0,
+ selectedValue: [] as any,
+ allSelected: true,
+ }),
+ env: createVariable({
+ name: 'env',
+ type: 'QUERY',
+ order: 1,
+ selectedValue: 'prod',
+ }),
+ },
+ });
+
+ const { doAllVariablesHaveValuesSelected } = getVariableDependencyContext();
+ expect(doAllVariablesHaveValuesSelected).toBe(true);
+ });
+
it('should report false when a DYNAMIC variable has empty selectedValue and allSelected is not true', () => {
setDashboardVariablesStore({
dashboardId: 'dash-1',
diff --git a/frontend/src/providers/Dashboard/store/dashboardVariables/dashboardVariablesStore.ts b/frontend/src/providers/Dashboard/store/dashboardVariables/dashboardVariablesStore.ts
index 13d6df5ec4..a20a5ec7f8 100644
--- a/frontend/src/providers/Dashboard/store/dashboardVariables/dashboardVariablesStore.ts
+++ b/frontend/src/providers/Dashboard/store/dashboardVariables/dashboardVariablesStore.ts
@@ -76,7 +76,7 @@ export function getVariableDependencyContext(): VariableFetchContext {
(variable) => {
if (
variable.type === 'DYNAMIC' &&
- variable.selectedValue === null &&
+ (variable.selectedValue === null || isEmpty(variable.selectedValue)) &&
variable.allSelected === true
) {
return true;