From f915df172ae85896afbc6cb76df559014900a171 Mon Sep 17 00:00:00 2001 From: Umberto Sgueglia Date: Mon, 16 Mar 2026 16:24:11 +0100 Subject: [PATCH 1/3] feat: update insightsProject slug Signed-off-by: Umberto Sgueglia --- backend/src/services/segmentService.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backend/src/services/segmentService.ts b/backend/src/services/segmentService.ts index aa32044f5a..42f4243067 100644 --- a/backend/src/services/segmentService.ts +++ b/backend/src/services/segmentService.ts @@ -69,6 +69,15 @@ export default class SegmentService extends LoggerBase { }) } + if (isSegmentSubproject(segment) && data.slug) { + const collectionService = new CollectionService({ ...this.options, transaction }) + const projects = await collectionService.findInsightsProjectsBySegmentId(segment.id) + if (projects.length > 0) { + const normalizedSlug = data.slug.replace(/^nonlf_/, '') + await collectionService.updateInsightsProject(projects[0].id, { slug: normalizedSlug }) + } + } + await SequelizeRepository.commitTransaction(transaction) return await this.findById(id) From c72ae523c11c651197e94c87624acfefc655d34d Mon Sep 17 00:00:00 2001 From: Umberto Sgueglia Date: Mon, 16 Mar 2026 17:09:57 +0100 Subject: [PATCH 2/3] fix: prevent update slug if it does not changed Signed-off-by: Umberto Sgueglia --- backend/src/services/segmentService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/services/segmentService.ts b/backend/src/services/segmentService.ts index 42f4243067..e53267a676 100644 --- a/backend/src/services/segmentService.ts +++ b/backend/src/services/segmentService.ts @@ -69,7 +69,7 @@ export default class SegmentService extends LoggerBase { }) } - if (isSegmentSubproject(segment) && data.slug) { + if (isSegmentSubproject(segment) && data.slug && data.slug !== segment.slug) { const collectionService = new CollectionService({ ...this.options, transaction }) const projects = await collectionService.findInsightsProjectsBySegmentId(segment.id) if (projects.length > 0) { From 2dc232a15c130e4351c3d2a594fb86f5e7db1f59 Mon Sep 17 00:00:00 2001 From: Umberto Sgueglia Date: Mon, 16 Mar 2026 17:20:54 +0100 Subject: [PATCH 3/3] fix: update also security updatedAt tables Signed-off-by: Umberto Sgueglia --- backend/src/services/collectionService.ts | 4 +++- .../data-access-layer/src/collections/index.ts | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/backend/src/services/collectionService.ts b/backend/src/services/collectionService.ts index 74bfd1d84e..302d63ba94 100644 --- a/backend/src/services/collectionService.ts +++ b/backend/src/services/collectionService.ts @@ -455,7 +455,9 @@ export class CollectionService extends LoggerBase { } } - await this.syncRepositoryGroupsWithDb(qx, insightsProjectId, project.repositoryGroups) + if (project.repositoryGroups !== undefined) { + await this.syncRepositoryGroupsWithDb(qx, insightsProjectId, project.repositoryGroups) + } const txSvc = new CollectionService({ ...this.options, diff --git a/services/libs/data-access-layer/src/collections/index.ts b/services/libs/data-access-layer/src/collections/index.ts index d53649bfac..7921faaa17 100644 --- a/services/libs/data-access-layer/src/collections/index.ts +++ b/services/libs/data-access-layer/src/collections/index.ts @@ -332,6 +332,23 @@ export async function updateInsightsProject( await syncRepositoriesEnabledStatus(qx, id, enabledUrls) } + // When slug changes, ON UPDATE CASCADE propagates the new slug to securityInsights* tables + // but does not touch their updatedAt — update it explicitly so Tinybird picks up the change + if (project.slug) { + await qx.result( + `UPDATE "securityInsightsEvaluationSuites" SET "updatedAt" = NOW() WHERE "insightsProjectSlug" = $(slug)`, + { slug: project.slug }, + ) + await qx.result( + `UPDATE "securityInsightsEvaluations" SET "updatedAt" = NOW() WHERE "insightsProjectSlug" = $(slug)`, + { slug: project.slug }, + ) + await qx.result( + `UPDATE "securityInsightsEvaluationAssessments" SET "updatedAt" = NOW() WHERE "insightsProjectSlug" = $(slug)`, + { slug: project.slug }, + ) + } + return updated as IInsightsProject }