Skip to content

fix(api): CircleMembers add/remove target /members/add|remove with access_value; list returns flat mapping - #67

Merged
nycomp merged 1 commit into
mainfrom
fix/circle-members-endpoints
Oct 3, 2026
Merged

nycomp merged 1 commit into
mainfrom
fix/circle-members-endpoints

Conversation

@nycomp

@nycomp nycomp commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #42. The circle members sub-resource did not conform to the Campus API routes (campus weekly, campus/api/routes/circles.py):

  • add() POSTed the bare /members path with payload key "access" — the trailing-slash redirect lands on GET-only /members/ (405), and the API expects "access_value"
  • remove() DELETEd /members — same 405; the API expects DELETE /members/remove
  • list() unwrapped resp.json()["members"], raising KeyError — the API returns the flat {member_id: access_value} mapping as the body

Changes

CircleMembers now requests the endpoints the API actually exposes:

  • list(): GET /api/v1/circles/<id>/members/ (canonical route), returns resp.json() directly (annotation corrected to dict[str, int])
  • add(): POST /api/v1/circles/<id>/members/add with {"member_id": ..., "access_value": ...}
  • remove(): DELETE /api/v1/circles/<id>/members/remove with {"member_id": ...}

Updated tests/unit/test_nested_resources.py regression tests to the corrected endpoints and added coverage for add/remove request targets and payloads.

Testing

  • pytest tests/unit/test_nested_resources.py: 17 passed
  • Full suite: 120 passed

…; list returns flat mapping

CircleMembers.add()/remove() POSTed/DELETEed the bare /members path, which
werkzeug redirects to GET-only /members/ (405), and add() sent the payload
key "access" where the API expects "access_value". list() unwrapped a
"members" key that the API does not send (KeyError); the GET now targets
the canonical /members/ route and returns the flat {member_id:
access_value} mapping directly.

Fixes #42
@nycomp
nycomp merged commit 5e0cf20 into main Oct 3, 2026
2 checks passed
@nycomp
nycomp deleted the fix/circle-members-endpoints branch October 3, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(api): CircleMembers add/remove target the wrong endpoints; members.list() unwraps a key the API does not send

1 participant