-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Description
Welcome!
- Yes, I have searched for similar issues on GitHub and found none.
What did you do?
When fetching groups with GET /group/fetchAllGroups/{INSTANCE_NAME}, the API returns a list containing some groups without the subject key and without creation (or creation = null). Attempting to “repair” these entries by calling findGroupInfos (get_group(id)) only succeeds for a subset of affected groups; others remain without subject/creation even though the group exists.
Code:
@router.get("/")
async def get_groups() -> list[dict]:
try:
url = f"{BASE_URL}/group/fetchAllGroups/{INSTANCE_NAME}"
query = {"getParticipants": "false"}
response = requests.get(url, headers=EVOLUTION_API_HEADERS, params=query)
response.raise_for_status()
data = response.json()
print("Quantity of groups:", len(data))
if not isinstance(data, list):
print(f"Unexpected response format: {data}")
raise HTTPException(
status_code=500, detail="Invalid response format from API"
)
# Temporary handling of groups without subject
data_with_subject = [group for group in data if group.get("subject")]
print("Quantity of groups with subject:", len(data_with_subject))
data_without_subject = [group for group in data if not group.get("subject")]
print("Quantity of groups without subject:", len(data_without_subject))
if data_without_subject:
for group in data_without_subject:
try:
updated_group = await get_group(group.get("id"))
if updated_group.get("subject"):
data_with_subject.append(updated_group)
print(f"Group {group.get('id')} updated successfully")
except Exception as e:
print(f"Error updating group {group.get('id')}: {str(e)}")
continue
print("Quantity of groups with subject after update:", len(data_with_subject))
return data_with_subject
except requests.RequestException as e:
print(f"Error fetching groups: {str(e)}")
raise HTTPException(status_code=500, detail=f"Error fetching groups: {str(e)}")
except Exception as e:
print(f"Unexpected error: {str(e)}")
raise HTTPException(status_code=500, detail=f"Unexpected error: {str(e)}")
What did you expect?
fetchAllGroups returns consistent objects for every group with at least:
{
"id": "1203...@g.us",
"subject": "Group name",
"creation": 1719230845,
...
}
findGroupInfos returns a group given its id exists.
What did you observe instead of what you expected?
fetchAllGroups includes entries where subject is missing and/or creation is null.
For some of those same ids, findGroupInfos returns 404 Not Found.
Representative log:
Error fetching group: 404 Client Error: Not Found for url:
http://localhost:8080/group/findGroupInfos/teachy?groupJid=xxxxxxxxxxxxxxxxxx%40g.us&getParticipants=False
Error updating group xxxxxxxxxx@g.us: 500: Error fetching group: 404 ...
The group does appear in fetchAllGroups, but cannot be fetched by findGroupInfos using its id.
Screenshots/Videos
No response
Which version of the API are you using?
v2.3.2
What is your environment?
Windows
Other environment specifications
No response
If applicable, paste the log output
Quantity of groups: 239
Quantity of groups with subject: 191
Quantity of groups without subject: 48
Error fetching group: 404 Client Error: Not Found for url:
http://localhost:8080/group/findGroupInfos/teachy?groupJid=xxxxxxxxxxxxxxxxxx%40g.us&getParticipants=False
Error updating group xxxxxxxxxx@g.us: 500: Error fetching group: 404 ...
Additional Notes
No response