Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Accept that capabilities API may return an elements: undefined result

Oliver Günther36b83673d81b
diff --git a/frontend/src/app/core/apiv3/cache/cachable-apiv3-collection.ts b/frontend/src/app/core/apiv3/cache/cachable-apiv3-collection.ts
index 73857b758d9..8fd6b207e64 100644
--- a/frontend/src/app/core/apiv3/cache/cachable-apiv3-collection.ts
+++ b/frontend/src/app/core/apiv3/cache/cachable-apiv3-collection.ts
@@ -60,7 +60,7 @@ export abstract class CachableAPIV3Collection<
tap(
(response:R) => {
if (response instanceof CollectionResource) {
- response.elements.forEach(this.touch.bind(this));
+ response.elements?.forEach(this.touch.bind(this));
} else if (response instanceof HalResource) {
this.touch(response as any);
}
diff --git a/frontend/src/app/core/current-user/current-user.service.ts b/frontend/src/app/core/current-user/current-user.service.ts
index b6e52707afe..b5c107b8c2d 100644
--- a/frontend/src/app/core/current-user/current-user.service.ts
+++ b/frontend/src/app/core/current-user/current-user.service.ts
@@ -124,6 +124,8 @@ export class CurrentUserService {
// The current page is the only page, return the results.
return of(data.elements);
}),
+ // Elements may incorrectly be undefined here due to the way the representer works
+ map((elements) => elements || []),
)
.subscribe((capabilities) => {
this.currentUserStore.update((state) => ({