Repository navigation
fix: bug sweep — timetable envelopes, session cleanup, oauth device flow - #70
Merged
Merged
Conversation
Self-contained fixes verified against campus weekly (74738e1); no API
or model changes, no other-service impact.
api:
- Timetables.list() unwraps the {"data": [...]} envelope instead of
iterating it (crash: TypeError on string keys) — closes #54
- Timetables.new() unwraps the {"data": ...} create envelope
- Timetable.get() unwraps the {"timetable": ...} envelope and parses
into campus.model.Timetable (was returning the raw envelope dict)
- Timetable.Metadata.get() parses TimetableMetadata (was Timetable)
- Timetable.Metadata.update() implemented: PATCH start_date+end_date
(both required by the route); was a NotImplementedError stub
auth:
- CampusSessions._session_key() yields "campus_session_id", not
"_session_id" (trailing-slash path split gave an empty provider;
matches the server-side provider session-key convention)
- Session.finalize() and Login.revoke() clear the Flask session key
with pop(key, None) — a missing key no longer raises KeyError/500
after the remote op succeeded — closes #59
- OAuth device flow posts the real /auth/v1/oauth/... routes
(device_authorize, token, device/authorize); absolute /oauth/...
paths missed the /auth/v1 prefix and 404 (auth sets strict_slashes)
- poll_for_token() maps RFC 8628 errors to AuthenticationError with
details={"oauth_error": ...} — the old error_code= kwarg was not an
APIError parameter and raised TypeError instead
- ClientAccess.get() requests /access/ with its trailing slash (route
rule + strict_slashes; slash-less path 404'd)
- Auth.finalize() step 4 actually verifies the user exists (.get());
it previously constructed the resource object as a no-op
- LoginSessions.new() parses the create response once
Regression tests: test_timetable.py, test_oauth_device_flow.py,
test_sessions.py, test_token_refresh.py; access-slash cases added to
test_auth_clients.py; metadata-get test moved to TimetableMetadata.
This was referenced Oct 4, 2026
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.
Self-contained bug sweep verified against campus
weekly(74738e1). No API redesign, no model changes, no impact on other services (campus-cli has its own device-flow implementation and does not importcampus_python.auth.v1.oauth).Bugs fixed
api (timetable) — closes #54
Timetables.list()unwraps the{"data": [...]}envelope; previously iterated the envelope dict and crashed withTypeError: string indices must be integers.Timetables.new()unwraps the{"data": <resource>}create envelope (route returns 200 + envelope, not 201).Timetable.get()unwraps the{"timetable": <resource>}envelope and parses intocampus.model.Timetable; previously returned the raw envelope while declaringcampus.model.Timetable.Timetable.Metadata.get()parsesTimetableMetadata(wasTimetable.from_resourceagainst its declared return type).Timetable.Metadata.update()implemented — the route is live server-side and requiresstart_date+end_datetogether; was aNotImplementedErrorstub.auth — closes #59
CampusSessions._session_keynow yieldscampus_session_id;path.split("/")[-1]on"sessions/campus/"produced"", storing login state under the generic_session_idkey (server provider convention:f"{PROVIDER}_session_id", campus/auth/provider.py:62).Session.finalize()/Login.revoke()clear the Flask key withpop(key, None)— a missing key (expired cookie, worker restart, lost session) no longer turns an already-successful remote op into a 500 KeyError./auth/v1/oauth/device_authorize,/auth/v1/oauth/token,/auth/v1/oauth/device/authorizeroutes; the old absolute/oauth/...paths missed the/auth/v1prefix and 404 (auth app setsstrict_slashes = True).poll_for_token()maps RFC 8628 error responses toAuthenticationError(details={"oauth_error": ...})— readable via the existingAPIError.oauth_errorproperty. The old call passederror_code=, which is not anAPIError.__init__parameter, so the intended error type raisedTypeErrorinstead.ClientAccess.get()requests/access/with its trailing slash (rule/<client_id>/access/+strict_slashes; the slash-less path 404'd on real deployments).Auth.finalize()step 4 ("Ensure user exists") actually calls.get()now — it previously constructed the resource object as a no-op. Safe: the server provisions the user duringverify_loginbefore the callback.LoginSessions.new()parses the create response once instead of twice.Tests
test_timetable.py(envelopes + metadata update),test_oauth_device_flow.py(paths + RFC 8628 error mapping),test_sessions.py(campus_session_idkey, finalize/revoke without session key),test_token_refresh.py(refreshed token is returned, not the stale one).test_auth_clients.py(access trailing slash),test_nested_resources.py(metadata-get pinsTimetableMetadata).146 passed (was 124).
Also fixed in passing
Campus._get_token_from_sessionnow returns the refreshed token — the refresh-token grant rotates server-side, but the method handed back the staleuser_creds.tokenit had just replaced.Not in scope (filed separately / existing issues)