Skip to content

Fix nested resources dropping their path part (405 on responses/feedback/links/entries/metadata/members) - #41

Merged
nycomp merged 1 commit into
mainfrom
bugfix/nested-resource-paths
Sep 30, 2026
Merged

nycomp merged 1 commit into
mainfrom
bugfix/nested-resource-paths

Conversation

@nycomp

@nycomp nycomp commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Nested Resource classes were constructed without their path part, so their paths collapsed onto the parent resource's path. Any collection-style call (responses.add(...), feedback.add(...), links.add(...), timetable Entries/Metadata, circle members) hit the parent resource's URL with the wrong method and failed with 405 Method Not Allowed.

Fixes #38

Changes

  • Pass the path part at construction for all nested resources:
  • Drop end_slash=True from Entries.list() / Metadata.get() so they request the leaf routes (/timetable/<id>/entries, /timetable/<id>/metadata) without trailing slashes — otherwise these would 404 against the API's Flask routes
  • Pass Assignments.list() filters via the client's query argument (the old params= kwarg raised TypeError: CampusRequest.get() only accepts query)

All corrected request paths verified against the Campus API routes (campus-suite, weekly branch):

Call Request path
submissions[id].responses.add(...) POST /api/v1/submissions/<id>/responses
submissions[id].feedback.add(...) POST /api/v1/submissions/<id>/feedback
submissions[id].submit() POST /api/v1/submissions/<id>/submit
assignments[id].links.add(...) POST /api/v1/assignments/<id>/links
timetable[id].entries.list() GET /api/v1/timetable/<id>/entries
timetable[id].metadata.get() GET /api/v1/timetable/<id>/metadata
circles[id].members.list() GET /api/v1/circles/<id>/members

Testing

Out of scope (follow-up)

CircleMembers.add/remove still target the bare /members URL and send an "access" payload key, while the API expects POST /members/add / DELETE /members/remove with access_value; members.list() also unwraps resp.json()["members"] though the API returns the flat mapping directly. These are a separate endpoint-conformance defect from the path collapse fixed here and deserve their own issue.

Nested Resource classes (Submission.responses/feedback, Assignment.links,
Timetable Entries/Metadata, Circle.members) were constructed without their
path part, so their paths collapsed onto the parent resource's path and
collection-style calls hit the parent URL with the wrong method (405).

Also drop end_slash=True from Timetable Entries.list()/Metadata.get() so
they request the API's leaf routes without trailing slashes, and pass
Assignments.list() filters via the client's query argument.

Fixes #38
@nycomp
nycomp merged commit d76e8be into main Sep 30, 2026
2 checks passed
@nycomp
nycomp deleted the bugfix/nested-resource-paths branch September 30, 2026 05:07
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.

Nested resources drop the parent path: Submission.responses/feedback and Assignment.links POST to the parent URL (405)

2 participants