bcgov / bcgov/SIMS

BUG: Student sync without an associated account is logged as unhandled

Open
#6,574 0 comments 0 reactions 1 assignee Claimed by @uhelm View on GitHub
Dominant language
TypeScript
Stars
29
Forks
15
Avg merge
1d 13h
Merged PRs (30d)
40

Description

**Describe the Bug**

A `PATCH /api/students/student/sync` request made before the user has an associated student account returns 401 and is emitted as an unhandled exception.

**Expected Behaviour**

- The missing-account condition is handled by the student synchronization flow and does not generate a misleading unhandled-exception error log.
- Prevent the `AppAllExceptionsFilter` from logging an error when the 401 during student login is an expected possible error to direct the student to create the profile.

**Actual Behaviour**

`RequiresStudentAccountGuard` rejects the request and `AppAllExceptionsFilter` records the expected response as unhandled.

**Log**

```text
[Nest] 18 - 09/04/2026, 5:26:35 AM LOG [AccessLoggerMiddleware] Request - PATCH /api/students/student/sync From [redacted] | User GUID: [redacted] | User Agent: Chrome 152 on Android
[Nest] 18 - 09/04/2026, 5:26:35 AM ERROR [AppAllExceptionsFilter] Unhandled exception, request path: /api/students/student/sync
{
"stack": "UnauthorizedException: The user does not have a student account associated.\n at RequiresStudentAccountGuard.canActivate (webpack://studentaid-backend/apps/api/src/auth/guards/student/requires-student-account.guard.ts:35:13)",
"response": { "message": "The user does not have a student account associated." },
"status": 401,
"message": "The user does not have a student account associated.",
"name": "UnauthorizedException"
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.