fix: allow empty affiliations array in PATCH project affiliations#3946
fix: allow empty affiliations array in PATCH project affiliations#3946
Conversation
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
2 similar comments
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
There was a problem hiding this comment.
Pull request overview
This PR updates the public members API PATCH handler for project affiliations to support clearing all affiliations by accepting an empty affiliations array, while only requiring verifiedBy when actually adding affiliations.
Changes:
- Allow
affiliations: []in the request body (removes the previous.min(1)constraint). - Make
verifiedByoptional in the schema, and enforce it conditionally whenaffiliationsis non-empty. - Skip inserting rows when clearing affiliations, while still deleting existing affiliations and triggering recalculation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
backend/src/api/public/v1/members/project-affiliations/patchProjectAffiliation.ts
Outdated
Show resolved
Hide resolved
backend/src/api/public/v1/members/project-affiliations/patchProjectAffiliation.ts
Show resolved
Hide resolved
…ojectAffiliation.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
Summary
affiliationsarray in PATCH/members/:memberId/project-affiliations/:projectIdto support removing all project affiliationsverifiedByoptional when clearing affiliations (still required when adding)Note
Low Risk
Low risk validation and persistence tweak confined to a single PATCH endpoint; main risk is client behavior changes when sending empty arrays and ensuring recalculation still behaves as expected.
Overview
Updates
PATCH /members/:memberId/project-affiliations/:projectIdto support clearing all affiliations by allowing an emptyaffiliationsarray.Makes
verifiedByoptional only whenaffiliationsis empty (enforced via a schema refine), and skipsinsertMemberSegmentAffiliationswhen no affiliations are provided while still deleting existing rows and triggering recalculation.Written by Cursor Bugbot for commit 34acf97. This will update automatically on new commits. Configure here.