Skip to content

Amaresh - Fix: Add Lost Time for project/team returns 404 due to missing personId lookup#2276

Open
amaresh2001 wants to merge 2 commits into
developmentfrom
amaresh/fix-lost-time-post-entry-404
Open

Amaresh - Fix: Add Lost Time for project/team returns 404 due to missing personId lookup#2276
amaresh2001 wants to merge 2 commits into
developmentfrom
amaresh/fix-lost-time-post-entry-404

Conversation

@amaresh2001

@amaresh2001 amaresh2001 commented Jul 18, 2026

Copy link
Copy Markdown

Description

POST /api/TimeEntry was returning a 404 ("User not found") for any lost-time entry of type project or team, so those entries silently failed to save even after the frontend fix in PR #4738 stopped the UI from erroring visibly. Root cause: postTimeEntryController unconditionally did UserProfile.findById(timeEntry.personId) and 404'd if no user was found, but project and team type lost-time entries never have a personId (only a projectId or teamId), so the lookup always failed for those two types.

Related PRS (if any):

This backend PR is related to the #4738 frontend PR.
To test this backend PR you need to checkout the #4738 frontend PR (branch shravya/bugfix/3824).

Main changes explained:

  • Update src/controllers/timeEntryController.js for making the UserProfile lookup/update in postTimeEntry conditional on entryType being person or default (the only types that carry a personId). For project/team entries, the user-profile lookup, the 404 guard, the deactivation check, the tangible/intangible hour updates, and the isFirstTimelog update are all skipped, and the time entry is saved directly. No behavior change for person/default entries.
  • Update src/controllers/timeEntryController.js for clearing the LostTeamEntry_* cache in postTimeEntry when a new team entry is added. ' editTimeEntryanddeleteTimeEntryalready did this, butpostTimeEntry(create) didn't, so newly-added team lost time sat behind a stale cached response for up to 5 minutes (the cache'sstdTTL`) before showing up under "Show Team Lost Time".

How to test:

  1. Check out this branch (amaresh/fix-lost-time-post-entry-404) and run npm install and npm run dev to run this PR locally
  2. Check out frontend PR #4738 (branch shravya/bugfix/3824) and run it locally, pointed at this backend
  3. Clear site data/cache
  4. Log in as a user with the Owner role
  5. Go to Reports page → scroll to the Lost Time section → click Add Lost Time
  6. Select Type: Project (or Team), fill in a project/team name, date, and time, then Submit
  7. Verify function "Add Lost Time" works: you get a success response (no 404) and the entry appears under Show Project Lost Time (or Show Team Lost Time)
  8. For Team specifically: click Show Team Lost Time first (to warm the cache), then submit a new Team entry, then click Show Team Lost Time again, verify the new entry appears immediately, not after a ~5 minute delay
  9. As a regression check, also submit a Person type entry and confirm it still works exactly as before

Screenshots or videos of changes:

Screenshot 2026-07-18 at 3 07 36 PM Screenshot 2026-07-18 at 3 08 16 PM Screenshot 2026-07-18 at 3 11 33 PM Screenshot 2026-07-18 at 3 20 49 PM

Note:

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.

1 participant