feat!: deprecate "Know Your Class and Section" and mark v4.0.0 release - #155
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes the deprecated Know Your Class and Section (KYCAS) feature end-to-end from the PESUAuth API because the upstream PESU Academy endpoint no longer works, and updates tests/docs/tooling accordingly.
Changes:
- Removes the
knowYourClassAndSectionrequest flag and the corresponding response payload/model/exception. - Deletes all KYCAS scraping/parsing logic from
PESUAcademy.authenticate()and associated tests. - Updates docs and benchmark tooling to drop KYCAS references and CLI support.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/test_request_model.py | Removes request-model tests that covered the now-removed KYCAS request flag; retains extra-field rejection coverage. |
| tests/unit/test_pesu.py | Drops unit tests and imports related to KYCAS fetch/parsing behavior; minor formatting tweaks. |
| tests/integration/test_app_integration.py | Removes integration coverage for KYCAS request/response behavior and validation. |
| tests/functional/test_authenticate_functional.py | Removes functional tests that exercised KYCAS behavior. |
| scripts/benchmark/util.py | Removes KYCAS payload flag from benchmark request construction. |
| scripts/benchmark/benchmark_requests.py | Removes KYCAS CLI flag and propagation into benchmark requests. |
| README.md | Removes KYCAS from API request/response documentation and examples. |
| app/pesu.py | Removes KYCAS constants and the KYCAS fetch path from authenticate(). |
| app/models/response.py | Removes the KYCAS field from the response schema. |
| app/models/request.py | Removes the KYCAS field from the request schema so it becomes a forbidden extra input. |
| app/models/kycas.py | Deletes the KYCAS response model. |
| app/models/init.py | Removes KYCAS model export from the models package. |
| app/exceptions/authentication.py | Removes the dedicated KYCAS fetch exception type. |
| app/docs/authenticate.py | Removes OpenAPI examples and error examples related to KYCAS. |
| app/app.py | Stops passing the removed KYCAS flag through the /authenticate route into PESUAcademy.authenticate(). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| | `fields` | Yes | `list[str]` | `None` | Which fields to fetch from the profile information. If not provided, all fields will be fetched | | ||
| | **Parameter** | **Optional** | **Type** | **Default** | **Description** | | ||
| | ------------- | ------------ | ----------- | ----------- | ----------------------------------------------------------------------------------------------- | | ||
| | `username` | No | `str` | | The user's SRN or PRN | |
Review: tested end-to-end — I've pushed the two fixes, good to merge once CI is greenReviewed at Rather than leave these as review comments, I pushed both changes straight to the branch — hope that's alright:
Detail on each below. The premise in #153 checks outWith a valid authenticated session + authenticated CSRF token, I reproduced this on a different account from the one in the issue (RR campus, different cohort), so it's neither account-specific nor transient — PESU has revoked the student role's access to that controller. Nothing we can do client-side, so removing the feature is the right call rather than trying to repair the request. Expected behaviour from #153 — matches exactlyAgainst the container built from this branch:
Docker build also verified end-to-end (the description has that box unchecked): image builds on Test suiteWith (Minor note on the description's numbers — before my commits, 1.
|
The three deprecation tests removed in d418959 were the only coverage pinning that the "Know Your Class and Section" keys are rejected, which is the behaviour pesu-dev#153 asks this PR to guarantee. Each one still passes verbatim against this branch, so restore them: - test_integration_authenticate_deprecated_know_your_class_and_section_key_rejected - test_integration_authenticate_deprecated_institute_name_in_fields_rejected - test_validate_deprecated_know_your_class_and_section_key_rejected Without them the only remaining coverage is the generic unknown-extra-key tests, which would keep passing if knowYourClassAndSection were ever reintroduced into RequestModel. Also add tests for the contracts this PR newly introduces, which were untested: - the camelCase knowYourClassAndSection key is rejected with 400, the literal payload from the issue - the removed KYCAS-only field names (cycle, department, instituteName) are rejected as `fields` values Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Coun9gitMaSfa58zivRJwQ
Removing knowYourClassAndSection from the request and response schemas is backward-incompatible, and 3.0.0 is already released and serving in production (main and dev are identical, and /openapi.json on the live deployment reports 3.0.0). Following the precedent of 4e14e18, which shipped the camelCase break as 3.0.0, this goes out as 4.0.0. OpenAPI's info.version is read from the installed package metadata, so without this bump / and /openapi.json would advertise the removal as part of 3.0.0. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Coun9gitMaSfa58zivRJwQ
Nothing has read this variable since the branch_short_code deprecation in 22e3d4b — it is absent from the tests, the benchmark scripts and the TEST_* env list in the pre-commit workflow, so it only misleads anyone filling in a fresh .env. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Coun9gitMaSfa58zivRJwQ
Update — everything from the review above is now addressedAll three points I raised are closed, and I've refreshed the title and description. Head is now
Verification on the final head
Title and description
Nothing outstanding from my side — good to merge. |
aditeyabaral
left a comment
There was a problem hiding this comment.
Approving at 350e66b. Full detail in the review and update comments; summarising what I checked:
The removal is justified and complete. POST /Academy/a/getStudentClassInfo returns 403 Access denied for student role with a valid authenticated session and CSRF token, reproduced on a second account from a different campus and cohort than the issue report — a permanent loss of the endpoint for the student role, not something fixable client-side. Every KYCAS identifier is gone from the models, app/pesu.py, the exception class, OpenAPI examples, README and the benchmark scripts, and /openapi.json exposes only ProfileModel, RequestModel, ResponseModel.
Behaviour matches #153 exactly. The reported payload returns 400 body.knowYourClassAndSection: Extra inputs are not permitted, message-identical to the issue's expected output, with the snake_case key, the removed fields values, the happy paths, field filtering, wrong-password 401 and the other three routes all verified against a container built from this branch.
Test deletions reviewed individually. The remaining removals are all genuinely dead: the functional test_authenticate_without_kycas asserted the behaviour of a parameter that no longer exists, and the DEFAULT_FIELDS invariant dropped by test_default_fields_includes_kycas_relevant_fields is still covered at tests/unit/test_pesu.py:479. The three that were not dead are restored in 0246480, along with the previously untested camelCase and fields contracts.
Final state: 79 tests passing at 99.38% coverage with app/pesu.py at 100%, ruff clean, Docker image builds and reports 4.0.0, and all 8 CI checks green.
Thanks for the thorough removal work here — the sweep across docs, benchmarks and OpenAPI examples was genuinely complete, which made this an easy one to verify.
📌 Description
This PR removes the deprecated
knowYourClassAndSectionfeature because the corresponding PESU Academy endpoint,/Academy/a/getStudentClassInfo, no longer works.The removal includes:
knowYourClassAndSectionfrom the authentication request schema.knowYourClassAndSectionfrom the authentication response schema.Requests containing
knowYourClassAndSectionare now treated like any other unknown request field and return a400validation response.🧱 Type of Change
requirements.txt,pyproject.toml🧪 How Has This Been Tested?
tests/unit/)tests/functional/)tests/integration/)Testing performed:
uv run pytest -m 'not secret_required'TEST_*credentials were unavailable.TEST_*credentials populated (maintainer review):uv run ruff check .andruff format --checkknowYourClassAndSectionis absent from both request and response models.✅ Checklist
scripts/run_tests.py)pre-commit run --all-files).envvars updated (if applicable)scripts/benchmark/benchmark_requests.py)🛠️ Affected API Behaviour
app/app.py– Modified/authenticateroute logicapp/pesu.py– Updated scraping or authentication handling🧩 Models
app/models/request.py– Input validation or request schema changesapp/models/response.py– Authentication response formattingapp/models/profile.py– Profile extraction logic🐳 DevOps & Config
Dockerfile– Changes to base image or build process.github/workflows/*.yaml– CI/CD pipeline or deployment updatespyproject.toml/requirements.txt– Project version bumped to4.0.0anduv.lockre-locked (no dependency changes).pre-commit-config.yaml– Linting or formatting hook changes.env.example– Dropped the deadTEST_BRANCH_SHORT_CODEvariable📊 Benchmarks & Analysis
scripts/benchmark/benchmark_requests.py– Removed support for the deprecated request flagscripts/benchmark/analyze_benchmark.py– Benchmark result analysis changesscripts/run_tests.py– Custom test runner logic or behavior updates📸 Screenshots / API Demos
Example response when a client continues to send the removed field:
{ "status": false, "message": "Could not validate request data - body.knowYourClassAndSection: Extra inputs are not permitted" }The generated OpenAPI request and response schemas no longer include
knowYourClassAndSection.🔄 Update — maintainer commits
Pushed to this branch during review (see the review comment for the reasoning and test evidence):
0246480knowYourClassAndSectionkey, andcycle/department/instituteNameasfieldsvalues.b31d8354.0.0(+uv.lock).3.0.0is already released and serving in production, so a breaking change cannot ride inside it.350e66bTEST_BRANCH_SHORT_CODEfrom.env.example, unread since 22e3d4b.The upstream 403 was independently reproduced on a second account (different campus and cohort from the issue report):
POST /Academy/a/getStudentClassInforeturns403 Access denied for student roleeven with a valid authenticated session and CSRF token, so this is a permanent loss of the endpoint for the student role rather than anything fixable client-side.🧠 Additional Notes — Migration to v4.0.0
This is a breaking API change, shipping as v4.0.0.
knowYourClassAndSectionfrom authentication requests entirely. Sending the key at all is now a400— including"knowYourClassAndSection": false. Clients that explicitly opted out must delete the key rather than set it tofalse.knowYourClassAndSectionin authentication responses. The key is gone from the response schema.cycle,departmentandinstituteNameare no longer validfieldsvalues and now return400.know_your_class_and_sectionargument toPESUAcademy.authenticate().The normal profile response continues to provide supported fields such as
semesterandsection.