Conversation
Deploying modl-admin with
|
| Latest commit: |
834d908
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://21142b47.admin-d0r.pages.dev |
| Branch Preview URL: | https://dev.admin-d0r.pages.dev |
| lastActivityAt: normalizeDateValue(data.lastActivityAt), | ||
| loggedInIps: [], | ||
| isAuthenticated: true, | ||
| isAuthenticated: data.isAuthenticated ?? true, |
There was a problem hiding this comment.
Validate login state
This returns data.isAuthenticated directly whenever the field is present. If the API returns a string value such as "false", the runtime value becomes a truthy string and callers like ProtectedRoute can treat the login as authenticated until the session refetch corrects it. Keep the mapper consistent with mapSessionPayload by only accepting a real boolean true as authenticated.
| isAuthenticated: data.isAuthenticated ?? true, | |
| isAuthenticated: data.isAuthenticated === true, |
Prompt To Fix With AI
This is a comment left during a code review.
Path: client/src/lib/services/auth-service.ts
Line: 67
Comment:
**Validate login state**
This returns `data.isAuthenticated` directly whenever the field is present. If the API returns a string value such as `"false"`, the runtime value becomes a truthy string and callers like `ProtectedRoute` can treat the login as authenticated until the session refetch corrects it. Keep the mapper consistent with `mapSessionPayload` by only accepting a real boolean `true` as authenticated.
```suggestion
isAuthenticated: data.isAuthenticated === true,
```
How can I resolve this? If you propose a fix, please make it concise.| }, | ||
|
|
||
| async updateAlert(id: string, payload: AlertPayload): Promise<SystemAlert> { | ||
| const raw = await requestJsonRaw<unknown>(`/v1/admin/alerts/${id}`, { |
There was a problem hiding this comment.
Encode alert ids
The alert id is interpolated directly into the URL path. If an id contains path-significant characters like /, ?, #, or %, the request can be routed to the wrong endpoint or have part of the id interpreted as a query or fragment. Encode the path segment before building the update URL.
| const raw = await requestJsonRaw<unknown>(`/v1/admin/alerts/${id}`, { | |
| const raw = await requestJsonRaw<unknown>(`/v1/admin/alerts/${encodeURIComponent(id)}`, { |
Prompt To Fix With AI
This is a comment left during a code review.
Path: client/src/lib/services/alerts-service.ts
Line: 82
Comment:
**Encode alert ids**
The alert id is interpolated directly into the URL path. If an id contains path-significant characters like `/`, `?`, `#`, or `%`, the request can be routed to the wrong endpoint or have part of the id interpreted as a query or fragment. Encode the path segment before building the update URL.
```suggestion
const raw = await requestJsonRaw<unknown>(`/v1/admin/alerts/${encodeURIComponent(id)}`, {
```
How can I resolve this? If you propose a fix, please make it concise.| async getAlerts(): Promise<SystemAlert[]> { | ||
| const raw = await requestJsonRaw<unknown>('/v1/admin/alerts'); | ||
| const items = isRecord(raw) && Array.isArray(raw.items) ? (raw.items as RawSystemAlert[]) : []; | ||
| return items.map(mapAlert); | ||
| }, |
There was a problem hiding this comment.
This reads items from the top-level response, but the other admin services unwrap the API envelope before mapping payloads. If /v1/admin/alerts returns the same shape as the rest of these endpoints, such as { success: true, data: { items: [...] } }, this returns an empty array and the Alerts page shows no alerts even when alerts exist.
| async getAlerts(): Promise<SystemAlert[]> { | |
| const raw = await requestJsonRaw<unknown>('/v1/admin/alerts'); | |
| const items = isRecord(raw) && Array.isArray(raw.items) ? (raw.items as RawSystemAlert[]) : []; | |
| return items.map(mapAlert); | |
| }, | |
| async getAlerts(): Promise<SystemAlert[]> { | |
| const raw = await requestJsonRaw<unknown>('/v1/admin/alerts'); | |
| const payload = isRecord(raw) && 'data' in raw ? raw.data : raw; | |
| const items = Array.isArray(payload) | |
| ? (payload as RawSystemAlert[]) | |
| : (isRecord(payload) && Array.isArray(payload.items) ? (payload.items as RawSystemAlert[]) : []); | |
| return items.map(mapAlert); | |
| }, |
Rule Used: This is a React frontend project on React 19 with ... (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: client/src/lib/services/alerts-service.ts
Line: 75-79
Comment:
**Unwrap alert responses**
This reads `items` from the top-level response, but the other admin services unwrap the API envelope before mapping payloads. If `/v1/admin/alerts` returns the same shape as the rest of these endpoints, such as `{ success: true, data: { items: [...] } }`, this returns an empty array and the Alerts page shows no alerts even when alerts exist.
```suggestion
async getAlerts(): Promise<SystemAlert[]> {
const raw = await requestJsonRaw<unknown>('/v1/admin/alerts');
const payload = isRecord(raw) && 'data' in raw ? raw.data : raw;
const items = Array.isArray(payload)
? (payload as RawSystemAlert[])
: (isRecord(payload) && Array.isArray(payload.items) ? (payload.items as RawSystemAlert[]) : []);
return items.map(mapAlert);
},
```
**Rule Used:** This is a React frontend project on React 19 with ... ([source](https://app.greptile.com/modl-gg/-/custom-context?memory=b7532101-0c9e-4ab6-b168-353a105ba593))
How can I resolve this? If you propose a fix, please make it concise.
Confidence Score: 4/5
This is close, but the alerts list parsing should be fixed before merging.
client/src/lib/services/alerts-service.ts
Important Files Changed
Prompt To Fix All With AI
Reviews (2): Last reviewed commit: "proto-json client compatibility" | Re-trigger Greptile
Context used: