Skip to content

Commit

Permalink
[ui] Sensor history: Fix tick ID variable (#23802)
Browse files Browse the repository at this point in the history
## Summary & Motivation

There is a bug on the sensor tick table where clicking to view a run
requested for a tick can show information about an unrelated tick.

This is because sensor tick IDs can be larger than JavaScript's
`Number.MAX_SAFE_INTEGER`, but they're being cast to `Number` for the
GraphQL variable. JS may cast the value to a number that doesn't match
the intended value, resulting in the wrong tick ID being sent in the
query.

We shouldn't be trying to represent them as `number` in JS. The GraphQL
input type expects it to be a BigInt, and we can just pass a string for
that.

## How I Tested These Changes

View sensor tick history with ticks that have tick IDs being cast to
incorrect values. Verify that the values are now correct, and that when
I click to view runs requested for the tick, the query variable and
rendered output are correct.

(cherry picked from commit 9e2898c)
  • Loading branch information
hellendag authored and jmsanders committed Aug 22, 2024
1 parent abd75f0 commit 9cf7d97
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const TickDetailsDialog = ({tickId, isOpen, instigationSelector, onClose}
};

interface InnerProps {
tickId: number | undefined;
tickId: string | undefined;
instigationSelector: InstigationSelector;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ export const TickHistoryTimeline = ({
afterTimestamp?: number;
statuses?: InstigationTickStatus[];
}) => {
const [selectedTickId, setSelectedTickId] = useQueryPersistedState<number | undefined>({
const [selectedTickId, setSelectedTickId] = useQueryPersistedState<string | undefined>({
encode: (tickId) => ({tickId}),
decode: (qs) => (qs['tickId'] ? Number(qs['tickId']) : undefined),
decode: (qs) => qs['tickId'] ?? undefined,
});

const [pollingPaused, pausePolling] = React.useState<boolean>(false);
Expand Down Expand Up @@ -348,7 +348,7 @@ export const TickHistoryTimeline = ({
const {ticks = []} = data.instigationStateOrError;

const onTickClick = (tick?: InstigationTick) => {
setSelectedTickId(tick ? Number(tick.tickId) : undefined);
setSelectedTickId(tick ? tick.tickId : undefined);
};

const onTickHover = (tick?: InstigationTick) => {
Expand All @@ -360,6 +360,7 @@ export const TickHistoryTimeline = ({
pausePolling(true);
}
};

return (
<>
<TickDetailsDialog
Expand Down Expand Up @@ -496,7 +497,7 @@ function TickRow({
) : null}
<TickDetailsDialog
isOpen={showResults}
tickId={Number(tick.tickId)}
tickId={tick.tickId}
instigationSelector={instigationSelector}
onClose={() => {
setShowResults(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const TickTagForRun = ({instigationSelector, instigationType, tickId}: Pr
isOpen={isOpen}
onClose={() => setIsOpen(false)}
instigationSelector={instigationSelector}
tickId={Number(tickId)}
tickId={tickId}
/>
</>
);
Expand Down

0 comments on commit 9cf7d97

Please sign in to comment.