Skip to content

Commit 3a8f9e8

Browse files
authored
[HUD] add validation for api/utilization page, and set max retry amount if api fails (#7499)
Weirdly high load coming from this api, I see a bunch of calls in vercel where its undefined, but since theres no check it goes to clickhouse and fails #7493 (comment)
1 parent 3d54b84 commit 3a8f9e8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

torchci/pages/api/utilization/[workflowId]/[jobId]/[attempt].ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ export default async function handler(
1818
};
1919

2020
try {
21+
// TODO: get better validation
22+
if (
23+
isNaN(parseInt(params.run_attempt)) ||
24+
isNaN(parseInt(params.workflow_id)) ||
25+
isNaN(parseInt(params.job_id))
26+
) {
27+
return res
28+
.status(400)
29+
.json({ error: `Invalid parameters: ${JSON.stringify(params)}` });
30+
}
31+
2132
const utilData = await fetchUtilization(params);
2233
if (utilData == null) {
2334
return res

torchci/pages/utilization/[workflowId]/[jobId]/[attempt]/[[...page]].tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ const JobUtilization = () => {
1111

1212
let { data, error } = useSWRImmutable(
1313
`/api/utilization/${workflowId}/${jobId}/${attempt}`,
14-
fetcherHandleError
14+
fetcherHandleError,
15+
{
16+
errorRetryCount: 3,
17+
}
1518
);
1619

1720
if (error) {

0 commit comments

Comments
 (0)