Return the login result even when the profile can't be fetched
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Ambito
- api, authentication, backend, documentation, testing
Direzione di ricerca
Wait for maintainer approval, then read CONTRIBUTING.md and inspect PESUAcademy.authenticate in app/pesu.py plus RequestModel and ResponseModel. Review app/docs/authenticate.py and tests/unit/test_openapi_docs.py before running the relevant tests. Done means the approved optional behavior, unchanged default behavior, documentation, models, metrics, and failure-type tests are covered.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
🔄 Updated for v5.0.0 (2026-10-08). Still open, and still needs a maintainer decision. 5.0.0 (#241) narrowed the problem: a single changed or missing profile field is now
nullrather than a failure, so only a structural change or PESU refusing the profile call fails the request. The background and the example message are updated to the new code.
💬 Needs a maintainer decision before implementation. This changes the API contract. Discuss the design below in the comments; once a maintainer approves it, the issue can be assigned.
Summary
When a caller asks for the profile and the profile step fails after a successful login, pesu-auth fails the whole request: a 502 if the page couldn't be fetched, and a 422 if it couldn't be parsed. The caller loses the one thing it most needs, which is confirmation that the credentials are valid.
Since 5.0.0, a single field PESU stops sending or sends in an unexpected shape no longer fails the request: it comes back as null. But if PESU Academy changes the profile response's structure, or stops serving it, every profile: true login fails until pesu-auth is fixed, and apps that use pesu-auth to sign students in are locked out completely, even though logging in still works.
Background
PESUAcademy.authenticate (app/pesu.py): the login succeeds, then _fetch_profile raises ProfileFetchError (502: PESU couldn't be reached, answered with a non-200, or declined to serve the profile, as it does for a non-student account) or ProfileParseError (422: the response's structure changed). Just before that, a login response without an access token raises UpstreamError (502). Any of these propagates out of authenticate. ResponseModel has no way to say "logged in, but no profile".
Proposed design (for discussion)
Add an optional request flag, keeping today's behaviour as the default so nothing breaks:
{ "username": "...", "password": "...", "profile": true, "profileRequired": false }
profileRequired: true(the default): unchanged, and profile failures fail the request.profileRequired: false: a profile failure after a successful login returns 200 withstatus: true, noprofile, and a newprofileErrorobject:
{
"status": true,
"message": "Login successful. Profile data could not be retrieved.",
"timestamp": "...",
"profileError": { "message": "Failed to parse the profile response from PESU Academy." }
}
Alternatives to weigh in the comments:
- Always degrade, with no flag. That's simpler, but it's a breaking change and needs a major version.
- Return a status other than 200 (for example 207). Unusual for JSON APIs, and clients would need to change.
Implementation plan (once approved)
RequestModel: addprofile_required: bool = True(camelCase aliasprofileRequired), with a description and an example.ResponseModel: add an optionalprofile_errorsub-model (messageonly; never raw exception text or HTML).authenticate: whenprofileis true andprofile_requiredis false, catchProfileFetchError/ProfileParseError(and the missing-tokenUpstreamError, which only happens after a successful login), keepstatus: True, and setprofileErrorfrom the exception's publicmessage, never its log-onlydetail. Metrics: the existingprofile_parse_errors_totalstill counts the parse failure;authentication_results_total{result="success"}is correct here.- Docs: the README request and response tables, and
app/docs/authenticate.py(a new example, whichtests/unit/test_openapi_docs.pychecks). - Tests: both flags with each failure type, the default unchanged, the response validates against the models, and OpenAPI examples.
Acceptance criteria
- A maintainer has approved a design in this issue
- Callers can opt in to getting a login result without a profile; the default behaviour is unchanged
- README, Swagger and tests cover the new fields
⚠️ PES University students only. This change sits in the login path and has to be tested end to end against PESU Academy with real PESU credentials (see "Tests that need credentials" in
CONTRIBUTING.md). Run the whole suite with your credentials in.envand paste the summary line into your PR. Every run makes real logins to PESU Academy, so run it when you need it, not in a loop.
How to contribute
- Wait until you're assigned. Comment to ask for this issue, then wait for a maintainer to assign it to you before writing any code. PRs for unassigned issues are closed without review.
- Read
CONTRIBUTING.mdfirst. It covers forking, setting up withuv, and running the tests. - Branch from
devin your fork, and open the PR againstdevwith a Conventional Commit title andCloses #189in the description. - Bump the minor version in
pyproject.tomland runuv lock(CI checks this).uv run pre-commit run --all-filesmust pass, and coverage must stay at 100%. - Update the README,
app/docs/and comments in the same PR as the behaviour they describe. - Never log, print, store or echo a password or token, including in tests, PR descriptions and screenshots.
- Lingua principale
- Python
- Stelle
- 22
- Fork
- 29
- Merge medio
- 22h 4m
- PR unite (30g)
- 19
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pesu-dev/auth
-
Check the README for dead links and fix the misleading Docker Hub badgeForse di nuovo libera @knownshah l’ha presa 17 giorni fa e non c’è nessuna pull request aperta. Apertadocumentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
pesu-dev/auth#220 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Run the same checks locally and in CI: pre-commit hooks in CI, and hooks that match CIForse già presa @achyu-dev l’ha presa 2 giorni fa. Apertabug tests and ci/cd
pesu-dev/auth#250 · 2 assegnatari ·
I maintainer di solito rispondono entro 1 giorno
-
bug documentation enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 54/100
I maintainer di solito rispondono entro 1 giorno
-
Commit SHA should be used instead of tag git based deployForse già presa @aditeyabaral l’ha presa 11 giorni fa. Apertabug
pesu-dev/auth#236 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Private Functions in `app.py` needs to be in separate fileForse già presa @aditeyabaral l’ha presa 11 giorni fa. Apertaapi enhancement
pesu-dev/auth#235 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di pesu-dev/auth
Issue simili
-
documentation good first issue
Difficoltà 2/5 Mezza giornata Idoneità per principianti 72/100
sujithputta02/Esapay#13 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Flaky: credential-proxy admission metric test asserts a wall-clock bound it does not establishApertaneeds-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
gke-labs/kube-agents#3277 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
jbacalso24/mimry#291 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 82/100
eli-alvarado/us-watchlist-alerts#14 ·
I maintainer di solito rispondono entro 1 giorno