Conversation
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
|
|
There was a problem hiding this comment.
Pull request overview
This PR ensures that when a leaf segment (sub-project) slug is updated, the corresponding insightsProjects.slug stays in sync, relying on existing FK ON UPDATE CASCADE behavior for related securityInsights* tables. It also aims to address a DAL bug when creating collections with omitted optional fields.
Changes:
- Sync
insightsProjects.slugwhen a sub-project segment’s slug changes (normalizing by strippingnonlf_). - Rely on existing
ON UPDATE CASCADEto propagateinsightsProjectSlugchanges tosecurityInsights*tables. - Fix
createCollectionto default optional fields (logoUrl,imageUrl,color) tonullwhen omitted.
Reviewed changes
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| backend/src/services/segmentService.ts | Updates linked insights project slug when a sub-project segment slug changes. |
| services/libs/data-access-layer/src/collections/index.ts | Adjusts collection creation to avoid errors when optional fields are omitted. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Summary
insightsProjects.slugis now automatically synced.securityInsights*tables (securityInsightsEvaluationAssessments,securityInsightsEvaluationSuites,securityInsightsEvaluations) get theirinsightsProjectSlugupdated automatically via theON UPDATE CASCADEforeign keyconstraint already in place (migration
V1753457861).Changes
backend/src/services/segmentService.tsIn the
update()method, when a leaf segment's slug changes, the linkedinsightsProjectis looked up bysegmentIdand itsslug is updated (stripping the
nonlf_prefix, consistent with the creation flow).services/libs/data-access-layer/src/collections/index.tsFixed a bug in
createCollectionwhere optional fields (logoUrl,imageUrl,color) were not defaulted tonull, causing apg-promise error when callers omitted them.
Note
Medium Risk
Touches slug propagation across
segments,insightsProjects, and downstreamsecurityInsights*tables; mistakes could desync identifiers or trigger unexpected updates for analytics consumers.Overview
Keeps
insightsProjects.slugin sync when a leafsegment(subproject) slug is updated by updating the linked insights project (withnonlf_prefix normalization) duringSegmentService.update().Makes
CollectionService.updateInsightsProject()only resync repository groups whenrepositoryGroupsis explicitly provided (avoiding unintended deletions), and updatesupdatedAtonsecurityInsightsEvaluationSuites,securityInsightsEvaluations, andsecurityInsightsEvaluationAssessmentswhen an insights project slug changes so downstream consumers (e.g. Tinybird) detect the cascade update.Written by Cursor Bugbot for commit b62af5f. This will update automatically on new commits. Configure here.