Fix: tagging block due to unauthorise request on /user/:id#630
Fix: tagging block due to unauthorise request on /user/:id#630DarrellRoberts wants to merge 7 commits into
Conversation
Code Review3 findings — 2 confirmed bugs, 1 plausible unsafe cast. 1. CONFIRMED — Editing a tagged comment with a cold cache silently strips all tag notifications
const initTags = (value: string) => {
if (!value || !users) return; // returns undefined
...
};
const currentTags = initTags(edit.editText); // undefined if cache cold
currentTags?.forEach(...) // no-op
// taggedPersonIds stays []
updateComment({ text: formattedText.trim(), taggedPersonIds }, ...);On first page load (TanStack Query cache cold), any coordinator who opens a comment to edit and saves — even without changing anything — will silently save with Fix: disable the Save button while the coordinators query is still loading, or let 2. CONFIRMED — Re-saving a comment with a deactivated user's tag permanently corrupts the stored text
matches.forEach((match) => {
const user = users.find(...);
if (user) {
freshlyFoundTags.push({ ... });
}
// absent user → silently dropped, nothing pushed
});
The original Fix: add an 3. PLAUSIBLE —
|
|
thanks @nadavosa ! I've pushed my latest changes which should address these edge cases |
nadavosa
left a comment
There was a problem hiding this comment.
-
personId: -1can reach the backend — ininitTags, unresolvable users getpersonId: -1pushed intofreshlyFoundTags. On edit save, that passes the deduplication check and lands intaggedPersonIdssent to the backend. Either filter outpersonId: -1before buildingtaggedPersonIds, or don't push the fallback tag intofreshlyFoundTagsat all. -
isUsersLoadingdisables comment button on page load — previouslyisTagFetchwas onlytrueduring an explicit async action. Now the button is disabled while the initial users query runs on mount. Low friction but a behaviour change. -
Truthy check on
personIdshould be!= null—if (user && user.personId)excludespersonId === 0. Rest of the PR uses== null/!= nullconsistently, same should apply here. -
PR checklist is all unchecked and issue number is
#ISSUE_ID— link the issue before merge.
…d-org/fe into darrell/fix/tagging-permissions
|
thanks @nadavosa , fixed |
Description
Tagging feature doesn't work because Coordinators can't fetch from
/user/:id.Now that
personIdis available on/user, we no longer need to fetch from/user/:idand can use the former endpointRelated Issues
Closes #659
Changes
Screenshots / Demos
Checklist