fix(group): use array-aware middleware on /group/participant#100
Open
netoduwe wants to merge 1 commit into
Open
fix(group): use array-aware middleware on /group/participant#100netoduwe wants to merge 1 commit into
netoduwe wants to merge 1 commit into
Conversation
The /group/participant route used ValidateJIDFields, which only handles single-string fields. Since participants is an array, every request was rejected with 400 "participants is required and cannot be empty" before reaching the handler. Switched to ValidateMultipleNumbers (same middleware /group/create uses) and dropped the unused "number" field.
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR fixes participant-related group actions by switching the /group/participant route to use the array-aware JID validation middleware consistent with /group/create, ensuring the participants array is validated correctly instead of being rejected by single-field middleware. Flow diagram for updated /group/participant middleware validationflowchart LR
A[Client POST /group/participant] --> B[ValidateMultipleNumbers participants]
B -->|valid participants array| C[UpdateParticipant]
B -->|invalid or empty participants| D[400 Bad Request]
%% highlight consistency with create route
E[Client POST /group/create] --> F[ValidateMultipleNumbers participants]
F -->|valid| G[CreateGroup]
F -->|invalid| D
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1 task
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.
POST /group/participantwas registered withValidateJIDFields("number", "participants"), which only handles single-string fields. Becauseparticipantsis an array, the type assertion fails and every request is rejected with400 "participants is required and cannot be empty"before reaching theUpdateParticipanthandler — breaking all participant actions (add / remove / promote / demote).This swaps to
ValidateMultipleNumbers("participants")— the same array-aware middleware already used by/group/createfor the same field — and drops the unused"number"argument.Reproduced on v0.6.1, 0.7.0, 0.7.1 and current main.
Related Issue
Closes #97
Type of Change
Summary by Sourcery
Bug Fixes: