Skip to content

Aakash - Urgent 🔥 (sync to development): volunteer dashboard tasks fail with 400 (backend) - #2405

Merged
one-community merged 1 commit into
developmentfrom
Aakash-hotfix-volunteer-dashboard-tasks-dev
Oct 14, 2026
Merged

one-community merged 1 commit into
developmentfrom
Aakash-hotfix-volunteer-dashboard-tasks-dev

Conversation

@vidiyala99

Copy link
Copy Markdown
Contributor

Same fix as #2404 (already merged into main and live on production), brought to development so the next release to main doesn't bring the bug back. The commit is cherry-picked unchanged; tests re-run on development.

Description

Since today's backend release to main (#2399, 3.17), the Dashboard's Team Member Tasks never loads for volunteers. GET /api/user/:userId/teams/tasks returns 400 {"error":{}} for every requestor without the seeNumberOfTimesTimeAdded permission (all volunteers). Admins and owners have that permission, so their dashboards still work. Reported by Jae on the account rukmangadaruku@gmail.com; I reproduced it on my own volunteer account on production (no extra permissions), so it is not caused by the new task deadlines permission.

Related PRs (if any):

Main changes explained:

  • Root cause: removeTaskExtensionCounts (taskController.js) hides deadlineCount by walking the response recursively. The team tasks response contains mongoose documents (populated teams), which hold references back to their parents, so the walk never ends: RangeError: Maximum call stack size exceeded. The catch block returns it as 400, and the empty {} body is the serialized RangeError.
  • Fix: strip deadlineCount from a plain JSON copy instead (JSON.parse(JSON.stringify(value))). That copy is exactly what res.send serializes anyway, so the response shape is unchanged, and it has no cycles.
  • getTaskById used the same function only for its in-place side effect; it now sends the returned copy (same fix for volunteers opening a single task).
  • Users with seeNumberOfTimesTimeAdded still receive deadlineCount unchanged.

How to test:

  1. Check out this branch, npm install, npm run build, npm start.
  2. npx jest src/controllers/taskController.spec.js: 59 tests pass, including 2 new ones (cyclic documents without the count permission return 200 with deadlineCount removed; with the permission it is kept).
  3. Log in as a Volunteer and open the Dashboard: Team Member Tasks loads (before: grey placeholder rows, console shows teams/tasks 400).
  4. Log in as an Admin/Owner: Team Member Tasks still loads and the "# of Times Time Added" count still shows.

Test evidence:

  • New test fails on the old code with the same production error (RangeError: Maximum call stack size exceeded) and passes with the fix.
  • Real-database check: the actual controller and helpers against an in-memory MongoDB seeded with two volunteers on one team and an assigned task. Before: 400 for a volunteer viewing their own tasks and a teammate's. After: 200 with the team member list and tasks.
  • Production, my volunteer account: 400 {"error":{}} before the fix, 200 after the deploy (see screenshots).

Screenshots (production, volunteer account)

Before the fix: Team Member Tasks stays on grey placeholder rows; GET /api/user/<id>/teams/tasks returned 400 {"error":{}}.
hotfix-2404-prod-before

After the fix (deployed 17:43 PT on 2026-10-13): the same dashboard lists the assigned tasks; the endpoint returns 200 and deadlineCount is left out for a volunteer.
hotfix-2404-prod-after

Note:

Production is already fixed by #2404 (Jae confirmed the reported account's dashboard loads). This PR only syncs development.

removeTaskExtensionCounts walked mongoose documents recursively to hide
deadlineCount. Documents reference their parents, so the walk never ended
(RangeError: Maximum call stack size exceeded) and the team tasks endpoint
returned 400 {"error":{}} for every user without seeNumberOfTimesTimeAdded,
i.e. all volunteers. It now strips the count from a plain JSON copy, which
is what res.send serializes anyway. getTaskById uses the returned copy too.
@sonarqubecloud

Copy link
Copy Markdown

@vidiyala99
vidiyala99 requested a review from nathanah October 14, 2026 02:21
@one-community
one-community merged commit ff77c17 into development Oct 14, 2026
4 checks passed
@one-community one-community changed the title Aakash - Urgent Hotfix (sync to development): volunteer dashboard tasks fail with 400 (backend) Aakash - Urgent 🔥 (sync to development): volunteer dashboard tasks fail with 400 (backend) Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants