Terms
Behavior
Summary
The bug is caused by an inconsistent response format from the organization events API.
When an organization has no events, the API returns a paginated object containing { results: [ ] }, while an organization with events returns a plain array. The frontend always calls .map() directly on the response, causing the events page to crash for organizations with no events.
Error
res.map is not a function
Screenshot
Steps to reproduce
- Create a new organization with no events.
- Visit
/organizations/<orgId>/events.
- The page shows error.
Root cause
Backend
OrganizationEventViewSet.list() in backend/communities/organizations/views.py returns different response shapes depending on whether events exist:
-
No events:
{
"count": 0,
"next": null,
"previous": null,
"results": []
}
-
Has events:
Frontend
fetchOrganizationEvents() in frontend/app/services/communities/organization/event.ts always expects a plain array:
return res.map(mapEvent);
When the organization has no events, res is an object rather than an array, causing:
res.map is not a function
Contribution
What would you prefer as the fix here: handling the response shape in the frontend, or making the backend return a consistent response format? I'm happy to work on either approach.
I'm happy to open a PR for the fix once this issue is confirmed.
Terms
Behavior
Summary
The bug is caused by an inconsistent response format from the organization events API.
When an organization has no events, the API returns a paginated object containing
{ results: [ ] }, while an organization with events returns a plain array. The frontend always calls.map()directly on the response, causing the events page to crash for organizations with no events.Error
res.map is not a functionScreenshot
Steps to reproduce
/organizations/<orgId>/events.Root cause
Backend
OrganizationEventViewSet.list()inbackend/communities/organizations/views.pyreturns different response shapes depending on whether events exist:No events:
{ "count": 0, "next": null, "previous": null, "results": [] }Has events:
[...]Frontend
fetchOrganizationEvents()infrontend/app/services/communities/organization/event.tsalways expects a plain array:When the organization has no events,
resis an object rather than an array, causing:res.map is not a functionContribution
What would you prefer as the fix here: handling the response shape in the frontend, or making the backend return a consistent response format? I'm happy to work on either approach.
I'm happy to open a PR for the fix once this issue is confirmed.