POST /group/participant always returns 400 "participants is required and cannot be empty" (wrong validation middleware on route)
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 88/100
Research direction
Start in pkg/routes/routes.go and compare the /group/participant registration with the /group/create route. Read jid_validation_middleware.go around the reported validation branch, then exercise POST /group/participant with the documented payload for each action. Done means the request reaches UpdateParticipant and returns the expected success response instead of the 400 validation error.
Written by the indexing model from the issue text.
Description
Welcome!
- Yes, I have searched for similar issues on GitHub and found none.
What did you do?
Called POST /group/participant to add a participant to a group, sending the exact payload documented in the Postman collection:
{
"groupJid": "120363332413160732@g.us",
"participants": ["557499879409"],
"action": "add"
}
Same result for every action (add / remove / promote / demote).
What did you expect?
The participant to be added to the group and the API to return {"message": "success"}, as the UpdateParticipant handler implements.
What did you observe instead of what you expected?
The request is always rejected with HTTP 400 and the body:
{"error": "participants is required and cannot be empty"}
regardless of the participants sent (raw number 557499879409 or full JID 557499879409@s.whatsapp.net).
Root cause: in pkg/routes/routes.go the route registers the wrong validation middleware:
routes.POST("/participant", r.jidValidationMiddleware.ValidateJIDFields("number", "participants"), r.groupHandler.UpdateParticipant)
ValidateJIDFields is designed for single-string fields. Since participants is an array, the type assertion value.(string) in the middleware fails, strValue defaults to "", and it aborts on the else if strValue == "" branch (jid_validation_middleware.go, line ~80) BEFORE reaching the handler. The handler UpdateParticipant is correct — the request never gets there.
Suggested fix (one line) — use the array-aware middleware already used by /group/create for the same participants field:
routes.POST("/participant", r.jidValidationMiddleware.ValidateMultipleNumbers("participants"), r.groupHandler.UpdateParticipant)
(The "number" field can be dropped: this route has no number field in its body.)
This means all participant actions (add / remove / promote / demote) are currently unusable via the API. Reproduced on v0.6.1, 0.7.0 and 0.7.1 — the route has had this middleware since at least v0.6.1.
Screenshots/Videos
No response
Which version are you using?
0.7.1 (also reproduced on 0.7.0 and 0.6.1)
What is your environment?
Linux
If applicable, paste the log output
Request: POST /group/participant
Body: {"groupJid":"120363040128842797@g.us","action":"add","participants":["554799009115@s.whatsapp.net"]}
Response: 400 {"error":"participants is required and cannot be empty"}
Additional Notes
The Postman collection and the UpdateParticipant handler are both correct — the mismatch is only in the middleware wired to the route. A PR changing that single line should fully resolve it.
- Dominant language
- Go
- Stars
- 878
- Forks
- 461
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from evolution-foundation/evolution-go
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Panic (nil pointer) in ReconnectClient kills the whole process - one instance takes down all others Open
Difficulty 4/5 3-5 days Newbie friendliness 55/100
All issues in evolution-foundation/evolution-go
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
enhancement needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
kind/cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
kubernetes-sigs/kueue#15947 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sympozium-ai/sympozium#627 ·