From 6cbd2d1807cc0d321f97e9cde1f0ee0e6bab356d Mon Sep 17 00:00:00 2001 From: Laurin Quast Date: Tue, 25 Nov 2025 15:30:19 +0100 Subject: [PATCH 1/3] fix integration test failing due to zero division --- .../providers/breaking-schema-changes-helper.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/services/api/src/modules/schema/providers/breaking-schema-changes-helper.ts b/packages/services/api/src/modules/schema/providers/breaking-schema-changes-helper.ts index b22c34defb8..c9fa618709e 100644 --- a/packages/services/api/src/modules/schema/providers/breaking-schema-changes-helper.ts +++ b/packages/services/api/src/modules/schema/providers/breaking-schema-changes-helper.ts @@ -36,7 +36,11 @@ export class BreakingSchemaChangeUsageHelper { return { topAffectedOperations: schemaChange.usageStatistics.topAffectedOperations.map(operation => { - const percentage = (operation.count / metadata.usage.totalRequestCount) * 100; + let percentage = (operation.count / metadata.usage.totalRequestCount) * 100; + if (percentage === Infinity) { + percentage = 0; + } + return { ...operation, percentage, @@ -44,7 +48,10 @@ export class BreakingSchemaChangeUsageHelper { }; }), topAffectedClients: schemaChange.usageStatistics.topAffectedClients.map(client => { - const percentage = (client.count / metadata.usage.totalRequestCount) * 100; + let percentage = (client.count / metadata.usage.totalRequestCount) * 100; + if (percentage === Infinity) { + percentage = 0; + } return { ...client, From e4c557b27d1ebf5d6d6a8ca64e099a9acaea9c11 Mon Sep 17 00:00:00 2001 From: Laurin Quast Date: Tue, 25 Nov 2025 15:43:04 +0100 Subject: [PATCH 2/3] fix --- .../breaking-schema-changes-helper.ts | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/services/api/src/modules/schema/providers/breaking-schema-changes-helper.ts b/packages/services/api/src/modules/schema/providers/breaking-schema-changes-helper.ts index c9fa618709e..187947a24c8 100644 --- a/packages/services/api/src/modules/schema/providers/breaking-schema-changes-helper.ts +++ b/packages/services/api/src/modules/schema/providers/breaking-schema-changes-helper.ts @@ -36,11 +36,15 @@ export class BreakingSchemaChangeUsageHelper { return { topAffectedOperations: schemaChange.usageStatistics.topAffectedOperations.map(operation => { - let percentage = (operation.count / metadata.usage.totalRequestCount) * 100; - if (percentage === Infinity) { - percentage = 0; - } - + // Note: + // "metadata.usage.totalRequestCount" is sometimes 0 in case of a integration test + // causing a zero devision and GraphQL exception, + // because we aggressively poll for the schema change after publishing usage data + // it seems like clickhouse slighty lags behind for the materialized view here. + // since it only happens in contetx of an integration test (no production issues) + // we can safely treat 0 as 1 request. + const totalRequestCount = Math.max(1, metadata.usage.totalRequestCount); + const percentage = (operation.count / totalRequestCount) * 100; return { ...operation, percentage, @@ -48,10 +52,15 @@ export class BreakingSchemaChangeUsageHelper { }; }), topAffectedClients: schemaChange.usageStatistics.topAffectedClients.map(client => { - let percentage = (client.count / metadata.usage.totalRequestCount) * 100; - if (percentage === Infinity) { - percentage = 0; - } + // Note: + // "metadata.usage.totalRequestCount" is sometimes 0 in case of a integration test + // causing a zero devision and GraphQL exception, + // because we aggressively poll for the schema change after publishing usage data + // it seems like clickhouse slighty lags behind for the materialized view here. + // since it only happens in contetx of an integration test (no production issues) + // we can safely treat 0 as 1 request. + const totalRequestCount = Math.max(1, metadata.usage.totalRequestCount); + const percentage = (client.count / totalRequestCount) * 100; return { ...client, From 3595bf2a59e95a028d13439b61715f2fbea1c23e Mon Sep 17 00:00:00 2001 From: Laurin Quast Date: Tue, 25 Nov 2025 15:44:37 +0100 Subject: [PATCH 3/3] Apply suggestions from code review --- .../schema/providers/breaking-schema-changes-helper.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/services/api/src/modules/schema/providers/breaking-schema-changes-helper.ts b/packages/services/api/src/modules/schema/providers/breaking-schema-changes-helper.ts index 187947a24c8..9472ea3cc61 100644 --- a/packages/services/api/src/modules/schema/providers/breaking-schema-changes-helper.ts +++ b/packages/services/api/src/modules/schema/providers/breaking-schema-changes-helper.ts @@ -41,7 +41,7 @@ export class BreakingSchemaChangeUsageHelper { // causing a zero devision and GraphQL exception, // because we aggressively poll for the schema change after publishing usage data // it seems like clickhouse slighty lags behind for the materialized view here. - // since it only happens in contetx of an integration test (no production issues) + // since it only happens in context of an integration test (no production issues) // we can safely treat 0 as 1 request. const totalRequestCount = Math.max(1, metadata.usage.totalRequestCount); const percentage = (operation.count / totalRequestCount) * 100; @@ -57,7 +57,7 @@ export class BreakingSchemaChangeUsageHelper { // causing a zero devision and GraphQL exception, // because we aggressively poll for the schema change after publishing usage data // it seems like clickhouse slighty lags behind for the materialized view here. - // since it only happens in contetx of an integration test (no production issues) + // since it only happens in context of an integration test (no production issues) // we can safely treat 0 as 1 request. const totalRequestCount = Math.max(1, metadata.usage.totalRequestCount); const percentage = (client.count / totalRequestCount) * 100;