Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Map the Hanumanth Nagar (HN) campus to campusCode 3

Aperta
#227 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@nishantjakane ci sta già lavorando.

Dal 3/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

api enhancement good first issue pesuacademy student profile

🔄 Updated for v5.0.0 (2026-10-08). Rewritten for 5.0.0 (#241). The campus is no longer worked out from the PRN's digit. campus is now the campus's institute name exactly as PESU Academy sends it (for example PES University (Ring Road)), and campusCode is mapped from that name by CAMPUS_CODES in app/pesu.py. #175's safe fallback is built in: an unknown name is returned as campus, with campusCode: null, a warning and an unknown_campus_code count, and the login still succeeds. So an HN student already gets a 200 today, just without a code. What's left is learning HN's exact institute name and mapping it to 3. The old dependency on #175 and the "HN" abbreviation no longer apply; the original guide is in the edit history.

🌱 This is a beginner-friendly issue. Add support for the Hanumanth Nagar (HN) campus, whose campus code is 3. It's a small change that shows how a profile travels from PESU Academy's mobile API, through app/pesu.py, into the response models and out of the API. Ask questions in the comments at any point.

⚠️ Who can take this issue

  • Anyone, for the code. The mapping, the model and the tests work fully offline with synthetic profiles.
  • But the exact campus name has to come from a real HN profile. If you have an HN account, or know an HN student willing to check theirs, you can verify it yourself (Step 1). If not, ask in the comments: a maintainer will help get it. Don't guess the name: a guess that is slightly wrong maps nothing.
  • Wait until you're assigned. Comment to ask for the issue, then wait for a maintainer to assign it to you before writing any code. PRs for unassigned issues are closed without review.

How campuses work now

In app/pesu.py:

# The campus code for each campus's institute name, as PESU writes it. The codes are the campus digit
# in the student's PRN and SRN, which is what this API has always returned. Checked against students
# of both campuses.
CAMPUS_CODES = {"PES University (Ring Road)": 1, "PES University (Electronic City)": 2}
  • campus comes from the profile response's STUDENT_PHOTO.instituteName (see StudentPhoto in app/models/upstream.py), returned as PESU wrote it.
  • campusCode is CAMPUS_CODES.get(campus), in PESUAcademy._campus_code. An unknown name gives null, increments profile_parse_errors_total{reason="unknown_campus_code"} and logs Unknown campus name: .... The rest of the profile is returned normally.
  • ProfileModel.campus_code in app/models/profile.py is Literal[1, 2] | None.

So for an HN student today, campus is whatever PESU calls the HN institute, and campusCode is null.

What you'll change

File Change
app/pesu.py Add HN's exact institute name → 3 to CAMPUS_CODES, and update its comment (which campuses it was checked against).
app/models/profile.py Allow Literal[1, 2, 3] for campus_code, and document 3 in its description. Keep strict validation and the camelCase alias.
tests/unit/test_pesu.py Add HN to the parametrized test_the_campus_is_the_institute_name_and_the_code_is_mapped_from_it, and change test_an_unknown_campus_name_is_returned_and_counted, which uses an invented PES University (Hanumanthanagar) as its unknown name: use a name that is obviously fictional instead.
README.md Document 3 in the campusCode row of the ProfileObject table.

Both the mapping and the model must change together. Adding the mapping alone would make the response fail validation (Literal[1, 2] rejects 3), which the authenticate route turns into a 500.

Step-by-step guide

Step 1: Find HN's exact institute name

This needs a real HN account, used only by its owner:

  • Log in to pesu-auth with profile: true (locally, or on https://pesuauth.onrender.com) and read campus from the response. It's exactly the string PESU sends. Also check that the PRN's campus digit is 3 (PES3...).
  • Also confirm that the login itself works. LOGIN_FORM in app/pesu.py sends instId: "1,6,7,14", the PES institutes a login is tried against. If an HN student can't log in at all, that list is the first suspect: say so in the comments, and don't change it without the evidence.
  • Post only the institute name and whether the login worked in the comments, never any other part of the profile, and never the credentials.
Step 2: Add HN to the mapping and the model
  • Add the name from Step 1 to CAMPUS_CODES with the value 3, and update the comment above it.
  • Allow exactly 1, 2 and 3 in ProfileModel.campus_code; don't replace the literal with an unrestricted integer, and don't derive it from CAMPUS_CODES.
  • Keep RR (1) and EC (2) as they are, and keep the unknown-campus behaviour for every other name.
Step 3: Write tests

Use synthetic profiles and the mocked HTTP fixtures in tests/unit/conftest.py (upstream, make_response, login_payload, profile_payload); never commit a real profile.

  • All three known names map to 1, 2 and 3, and none of them triggers the warning or the unknown_campus_code count.
  • An unknown name (obviously fictional) is still returned as campus with campusCode: null, the warning and one count.
  • An HN profile validates through ProfileModel and ResponseModel, and /authenticate returns it with a 200 (tests/unit/test_authenticate_flow.py drives the whole app with the upstream mocked).
  • fields=["campusCode", "campus"] returns both HN fields, and a selection without them omits them.
  • The published schema allows exactly 1, 2 and 3 (tests/unit/test_openapi_docs.py).

Then run:

uv run pytest tests/unit -q
uv run python scripts/run_tests.py

Coverage must stay at 100%, lines and branches. Report a run without live credentials as partial.

Step 4: Update the documentation
  • The README's ProfileObject table and the campus_code description.
  • If you add an HN response example to app/docs/authenticate.py, make it validate (tests/unit/test_openapi_docs.py checks every documented example).
  • The agent docs in pesu-dev/skills (auth/docs/api-contract.md, auth/docs/upstream.md) describe campuses too. Mention it in your PR so a maintainer updates them there; don't edit AGENTS.md, .agents/ or .github/agents/ in this repo.
Step 5: Open your PR
  • Bump the minor version in pyproject.toml (for example 5.0.0 → 5.1.0), then run uv lock, and commit both files. Call out the new campus code in the PR.
  • Run uv run pre-commit run --all-files and fix anything it reports.
  • Open the PR from your fork, against the dev branch.
  • Use a Conventional Commit title, for example feat: map the Hanumanth Nagar campus to campusCode 3.
  • Write Closes #227 in the PR description, and say how the institute name was verified.

Done when

  • HN's exact institute name was verified from a real profile and is mapped to 3
  • An HN profile returns campusCode: 3 with its campus name, and a 200
  • RR (1) and EC (2) are unchanged, and unknown names still fall back to null with the warning and count
  • The model and the published schema allow exactly 1, 2 and 3
  • Tests cover all of the above, and coverage is 100%
  • README and model descriptions document 3
  • Pre-commit passes, the version and lock file agree, and the PR is from your fork against dev

Want to go deeper?

The repo has detailed guides in .agents/pesudev-skills/auth/docs/. Run git submodule update --init if the folder is empty. They are being updated for 5.0.0; where they still describe the PRN digit or HTML scraping, the code wins.

Lingua principale
Python
Stelle
22
Fork
29
Merge medio
1g 3h
PR unite (30g)
19

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pesu-dev/auth

Tutte le issue di pesu-dev/auth

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.