We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7c9a65d commit b5132baCopy full SHA for b5132ba
services/libs/data-access-layer/src/segments/index.ts
@@ -66,10 +66,13 @@ export async function findSegmentById(
66
} else if (isSegmentSubproject(child)) {
67
// find project index
68
const projectIndex = acc.findIndex((project) => project.slug === child.parentSlug)
69
- if (!acc[projectIndex].subprojects) {
70
- acc[projectIndex].subprojects = [child]
71
- } else {
72
- acc[projectIndex].subprojects.push(child)
+ // process subproject only if its parent project exists
+ if (projectIndex !== -1) {
+ if (!acc[projectIndex].subprojects) {
+ acc[projectIndex].subprojects = [child]
73
+ } else {
74
+ acc[projectIndex].subprojects.push(child)
75
+ }
76
}
77
78
return acc
0 commit comments