Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: JS API viewports should throw only for basic data issues #6535

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ public void setInternalViewport(double firstRow, double lastRow, Column[] column
Boolean isReverseViewport) {
// Until we've created the stream, we just cache the requested viewport
if (status == Status.STARTING) {
if (firstRow < 0 || firstRow > lastRow) {
throw new IllegalArgumentException("Invalid viewport row range: " + firstRow + " to " + lastRow);
}
Comment on lines +253 to +255
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guessing you added this because it was in DHE?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct - trying to slightly better match semantics, especially since we removed the check in RangeSet that the ranges are ordered properly (as it was causing performance issues on subscriptions to large tables).

This is one of the few cases where we actually throw when calling setViewport in both APIs. When we get an api design for subscriptions that also handles preview and reverse viewports, we'll be more deliberate about how to handle these classes of errors...

this.firstRow = firstRow;
this.lastRow = lastRow;
this.columns = columns;
Expand All @@ -273,8 +276,12 @@ public void setInternalViewport(double firstRow, double lastRow, Column[] column
isReverseViewport = false;
}
RangeSet viewport = RangeSet.ofRange((long) firstRow, (long) lastRow);
this.sendBarrageSubscriptionRequest(viewport, Js.uncheckedCast(columns), updateIntervalMs,
isReverseViewport);
try {
this.sendBarrageSubscriptionRequest(viewport, Js.uncheckedCast(columns), updateIntervalMs,
isReverseViewport);
} catch (Exception e) {
fireEvent(JsTable.EVENT_REQUEST_FAILED, e.getMessage());
}
}

/**
Expand Down