Skip to content

Commit 43342c8

Browse files
vklimontovichclaude
andcommitted
fix(console): drop unused import and guard invalid audit-log date params
Removes the leftover `useRef` import that failed lint, and validates `from`/`to` URL params with dayjs.isValid() before seeding the range — a malformed value no longer builds an invalid Dayjs that serializes back as "Invalid Date" and poisons the request. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SeUP6H1fsHsJjo2FLKKqUS
1 parent b1329fb commit 43342c8

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

webapps/console/components/AuditLog/AuditLog.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useMemo, useRef, useState } from "react";
1+
import React, { useEffect, useMemo, useState } from "react";
22
import { Alert, Button, DatePicker, Select, Table, Tag, Tooltip } from "antd";
33
import dayjs, { Dayjs } from "dayjs";
44
import utc from "dayjs/plugin/utc";
@@ -275,9 +275,17 @@ export const AuditLog: React.FC<AuditLogProps> = ({ workspaceId, workspaceSlug,
275275
if (t.length) setTypes(t);
276276
if (s.length) setSeverities(s);
277277
if (o.length) setOrigins(o);
278-
const from = typeof q.from === "string" ? q.from : undefined;
279-
const to = typeof q.to === "string" ? q.to : undefined;
280-
if (from || to) setRange([from ? dayjs(from) : null, to ? dayjs(to) : null]);
278+
// Guard against malformed URL params: dayjs() happily builds an invalid
279+
// object from garbage, which would later serialize back as "Invalid Date"
280+
// and poison both state and the RPC request. Drop anything that isn't valid.
281+
const parseDate = (v: string | string[] | undefined) => {
282+
if (typeof v !== "string" || !v) return null;
283+
const d = dayjs(v);
284+
return d.isValid() ? d : null;
285+
};
286+
const from = parseDate(q.from);
287+
const to = parseDate(q.to);
288+
if (from || to) setRange([from, to]);
281289
if (adminView && typeof q.ws === "string" && q.ws) {
282290
// Carry the label in the URL too so the chip renders a name without an
283291
// extra lookup (the workspace search is keyed by name, not id).

0 commit comments

Comments
 (0)