MK8S-197 - UI update to include auth token#4827
MK8S-197 - UI update to include auth token#4827ChengYanJin wants to merge 10 commits intodevelopment/133.0from
Conversation
bed75df to
fbba288
Compare
0b309dd to
e001070
Compare
Hello chengyanjin,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
Peer approvals must include at least 1 approval from the following list: |
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
Peer approvals must include at least 1 approval from the following list: |
ce8df24 to
97eeed1
Compare
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
Peer approvals must include at least 1 approval from the following list: The following reviewers are expecting changes from the author, or must review again: |
|
|
||
| useEffect(() => { | ||
| if (userData?.token) { | ||
| setHeaders({ Authorization: `Bearer ${userData.token}` }); |
There was a problem hiding this comment.
ui/src/services/alertmanager/api.ts uses ApiClient (which goes through axios), but PrometheusAuthProvider only calls setHeaders on the Prometheus API client, not the AlertManager API client. The AlertManager requests from the UI side will still be unauthenticated. You need to also call setHeaders on the alertmanager API client with the Bearer token, similar to what you did for Prometheus.
— Claude Code
| }; | ||
| export function getAlerts(alertManagerUrl: string) { | ||
| return fetch(alertManagerUrl + '/api/v2/alerts') | ||
| export function getAlerts(alertManagerUrl: string, token: string) { |
There was a problem hiding this comment.
The token parameter is typed as string but it can be undefined (since userData?.token may be undefined). The type should be string | undefined to match the actual usage in AlertProvider.tsx line 26.
— Claude Code
| const { userData } = useAuth(); | ||
| const token = userData?.token; | ||
| const query = useQuery( | ||
| ['activeAlerts', token], |
There was a problem hiding this comment.
Including the token in the query key means every token refresh/rotation will invalidate the cache and refetch all alerts. Consider using a stable query key (e.g. just activeAlerts) since the token is only needed for the request, not for cache identity.
— Claude Code
| } | ||
| }, [userData?.token]); | ||
|
|
||
| if (!ready) return null; |
There was a problem hiding this comment.
PrometheusAuthProvider blocks rendering of the entire app (returns null) until the token is available. If userData is slow to resolve or temporarily undefined during token refresh, the entire UI will flash/unmount. Consider rendering children immediately and setting headers as a side effect without blocking, or showing a loading indicator instead of null.
— Claude Code
|
fa75385 to
d09944d
Compare
|
d09944d to
c15b1d0
Compare
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
Peer approvals must include at least 1 approval from the following list: The following reviewers are expecting changes from the author, or must review again: |
Review by Claude Code |
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
Peer approvals must include at least 1 approval from the following list: |
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
Peer approvals must include at least 1 approval from the following list: |
| const { userData } = useAuth(); | ||
| const token = userData?.token; | ||
|
|
||
| useEffect(() => { |
There was a problem hiding this comment.
Race condition: useEffect runs after render, so when token first becomes available, children render (and can trigger Prometheus API calls) before setHeaders has executed. Use useLayoutEffect instead to ensure headers are set before children mount.
— Claude Code
Review by Claude Code |
|
|
|
/approve |
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
Peer approvals must include at least 1 approval from the following list: The following options are set: approve |
No description provided.