MEDIUM: community/posts response shape inconsistent — total field missing in normal path #96

Closed
opened 2026-04-18 09:02:56 -07:00 by pyr0ball · 0 comments
Owner

Summary

GET /api/v1/community/posts returns different response shapes depending on whether the community DB is available.

When community DB is unavailable (most dev/local instances):

{"posts": [], "total": 0, "note": "Community DB not available on this instance."}

When community DB is available:

{"posts": [...], "page": 1, "page_size": 20}

The total field is present in the stub but absent from the real response. The note field is present in the stub but absent from the real response. The frontend may crash or behave incorrectly if it reads response.total.

Fix

Standardize the response shape. The normal path should include total:

return {
    "posts": [_post_to_dict(p) for p in posts if _visible(p)],
    "total": len(posts),  # or a real count query
    "page": page,
    "page_size": page_size
}

And the stub should match:

return {"posts": [], "total": 0, "page": page, "page_size": page_size,
        "note": "Community DB not available on this instance."}
## Summary `GET /api/v1/community/posts` returns different response shapes depending on whether the community DB is available. **When community DB is unavailable (most dev/local instances):** ```json {"posts": [], "total": 0, "note": "Community DB not available on this instance."} ``` **When community DB is available:** ```json {"posts": [...], "page": 1, "page_size": 20} ``` The `total` field is present in the stub but absent from the real response. The `note` field is present in the stub but absent from the real response. The frontend may crash or behave incorrectly if it reads `response.total`. ## Fix Standardize the response shape. The normal path should include `total`: ```python return { "posts": [_post_to_dict(p) for p in posts if _visible(p)], "total": len(posts), # or a real count query "page": page, "page_size": page_size } ``` And the stub should match: ```python return {"posts": [], "total": 0, "page": page, "page_size": page_size, "note": "Community DB not available on this instance."} ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Circuit-Forge/kiwi#96
No description provided.