Repository navigation
Fix nested resources dropping their path part (405 on responses/feedback/links/entries/metadata/members) - #41
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Nested
Resourceclasses 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(...), timetableEntries/Metadata, circlemembers) hit the parent resource's URL with the wrong method and failed with 405 Method Not Allowed.Fixes #38
Changes
Submission.Responses("responses"),Submission.Feedback("feedback")Assignment.Links("links")Timetable.Entries("entries"),Timetable.Metadata("metadata")Circle.CircleMembers("members")— same root cause as Nested resources drop the parent path: Submission.responses/feedback and Assignment.links POST to the parent URL (405) #38, not listed in the issueend_slash=TruefromEntries.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 routesAssignments.list()filters via the client'squeryargument (the oldparams=kwarg raisedTypeError:CampusRequest.get()only acceptsquery)All corrected request paths verified against the Campus API routes (campus-suite,
weeklybranch):submissions[id].responses.add(...)POST /api/v1/submissions/<id>/responsessubmissions[id].feedback.add(...)POST /api/v1/submissions/<id>/feedbacksubmissions[id].submit()POST /api/v1/submissions/<id>/submitassignments[id].links.add(...)POST /api/v1/assignments/<id>/linkstimetable[id].entries.list()GET /api/v1/timetable/<id>/entriestimetable[id].metadata.get()GET /api/v1/timetable/<id>/metadatacircles[id].members.list()GET /api/v1/circles/<id>/membersTesting
tests/unit/test_nested_resources.py: 15 regression tests covering path construction and actual request targets for every nested resourcepoetry run pytest, same as CI)/api/v1/submissions/<id>/responsesinstead of the collapsed parent pathOut of scope (follow-up)
CircleMembers.add/removestill target the bare/membersURL and send an"access"payload key, while the API expectsPOST /members/add/DELETE /members/removewithaccess_value;members.list()also unwrapsresp.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.