fix: SJIP-1606 scope resetAllConsents to live users - #126
Merged
Merged
Conversation
…RETURNING
The admin consent reset ran with an empty where clause, so it also
cleared the consent flags on soft-deleted users, and returning:true made
Postgres send back all 35 columns of every updated row only for the
count to be read off the array length and the rows discarded.
Filter on deleted:false and drop returning. Sequelize still yields the
affected-row count as result[0] without it -- derived from the driver's
rowCount rather than rows.length -- so the route's {updated: N} payload
keeps its shape. N now counts live users reset rather than total table
rows.
The flag was inherited verbatim in b6aa8b7, which collapsed the per-user
updateRolesAndDataUsages loop into one bulk update and emptied the where
clause while carrying returning:true across. It was already unused there.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
celinepelletier
approved these changes
Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PUT /admin/resetAllConsentsran with an emptywhere, so it cleared consentflags on soft-deleted rows too, and
returning: truemade Postgres send back all35 columns of every updated row only for the count to be read off the array length.
where: { deleted: false }— a soft-deleted row has a randomizedkeycloak_idthat matches no Keycloak subject, so it can never log in andre-consent. Resetting it was unreachable work that also overwrote its
updated_date(whichdeleteUserleaves as the user's last real profile edit).returning: true— sequelize still returns the count asresult[0],derived from the driver's
rowCountinstead ofrows.length.updatedcount in the response is now smaller: it counts live users reset,not total table rows.