Skip to content

Fix Import Dataset preview error display (Addresses #17985) - #18017

Merged
kevinushey merged 2 commits into
mainfrom
bugfix/17985-import-preview-error-display
Jun 18, 2026
Merged

kevinushey merged 2 commits into
mainfrom
bugfix/17985-import-preview-error-display

Conversation

@kevinushey

@kevinushey kevinushey commented Jun 18, 2026 •

Copy link
Copy Markdown
Collaborator

Addresses #17985.

Problem

The readr CSV preview subprocess occasionally fails to start on Windows CI. While the underlying cause of the subprocess failure is still under investigation, the frontend had a bug that prevented error messages from being displayed when the subprocess failed.

Root Cause

DataImportPreviewResponse.getErrorMessage() assumed the error message was always a JavaScript array and called join(' ') on it. When the C++ backend returned a string (the common case for subprocess failures like "Operation finished with error code."), this threw a TypeError: String.prototype.join is not a function and the error was silently swallowed.

As a result:

  1. The error was never displayed to the user
  2. The preview grid remained empty
  3. The e2e test waited the full 45s timeout before failing

Changes

Frontend (GWT/Java)

  • DataImportPreviewResponse.java: Handle both string and array error messages defensively using instanceof Array check
  • DataImportAssembleResponse.java: Apply the same defensive fix for consistency

Backend (C++)

  • SessionData.cpp: Always return error messages as an array so the frontend formats them consistently. Prefer the captured stderr output when present, falling back to the generic message only when no stderr was captured (so the array is never empty and the specific error isn't buried behind the generic one).

Tests

  • import_dataset.test.ts: When the preview times out, scrape the top-level "Error" dialog for a specific diagnostic (and soft-skip on Windows CI) instead of failing with only a generic timeout message.

Note

This fix ensures errors are properly displayed when the preview subprocess fails, but does not address the underlying cause of the subprocess startup failures on Windows CI. That investigation continues separately.

The readr CSV preview subprocess occasionally fails to start on Windows CI,
but the frontend never displayed the error message because

DataImportPreviewResponse.getErrorMessage() assumed the error message was
always a JavaScript array and called .join(' ') on it. When the C++ backend
returned a string (the common case for subprocess failures), this threw a
TypeError and the error was silently swallowed.

Changes:
- DataImportPreviewResponse.java: Handle both string and array error
  messages defensively using instanceof Array check
- DataImportAssembleResponse.java: Apply the same defensive fix for
  consistency
- SessionData.cpp: Always return error messages as arrays and include
  both the primary message and any stderr output
- import_dataset.test.ts: Check for error indicators early to fail fast
  with diagnostics instead of waiting 45s for a timeout
@kevinushey
kevinushey force-pushed the bugfix/17985-import-preview-error-display branch from 385b3f8 to b40df2b Compare June 18, 2026 06:58
@kevinushey kevinushey added this to the 2026.07 (Pacific Dogwood) milestone Jun 18, 2026
@github-actions

github-actions Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

🍎 macOS Desktop E2E · ARM64

❌ 1 test(s) failed

███████████████████░ 99% pass rate

✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
406 1 11 0
📥 Download Playwright report

⬇️ playwright-report.zip — extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


2 shards · macos-26 ARM64 · commit 26428740169711f81d30652fa2ee6fe410fa9553 · Run #100

@github-actions

github-actions Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

🪟 Windows Desktop E2E · Server 2025 x64

✅ All tests passed!

████████████████████ 100% pass rate

✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
403 0 16 1
📥 Download Playwright report

⬇️ playwright-report.zip — extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


2 shards · Windows Server 2025 x64 · commit 26428740169711f81d30652fa2ee6fe410fa9553 · Run #100

@kevinushey
kevinushey requested a review from gtritchie June 18, 2026 16:23
@gtritchie

Copy link
Copy Markdown
Member

Code review findings

Actionable items from an automated multi-agent review. Strengths, dismissed findings, and ratings are omitted. The core fix is correct for every backend message shape — the items below are in the test and comments, plus one C++ message-quality nit.

Important

  1. The fix ships untested. getErrorMessage() in DataImportPreviewResponse.java / DataImportAssembleResponse.java — the only test change touches a diagnostic on a path that is test.fixme-skipped on Windows CI, the very platform the bug occurs on. There is no positive assertion that a string-shaped error is now returned/displayed instead of swallowed. src/gwt/test/org/rstudio/studio/client/workbench/views/output/lint/model/LintItemTests.java is an in-repo precedent: a GWTTestCase that builds JavaScriptObject overlays and exercises their JSNI methods. Add a unit test over getErrorMessage() covering string / array / missing-error / missing-message — it's the only thing that would fail if the .join-on-string assumption were reintroduced.

  2. e2e/rstudio/tests/panes/environment/import_dataset.test.ts:48-56 — the new diagnostic scrapes dialog.locator('.gwt-Label'), but the preview error is surfaced via progressIndicator_.onError() → ModalDialogBase.onError → showErrorMessage() (ModalDialogBase.java:586-597), which renders a separate top-level error .gwt-DialogBox, not a label inside the import dialog. So the scrape will essentially never find the message and always falls back to the generic diagnostic. Retarget the error dialog (top-level .gwt-DialogBox with the error caption) instead. The accompanying comment ("uses the progress indicator's error label") is inaccurate for the same reason.

  3. src/gwt/.../dataimport/model/DataImportPreviewResponse.java:29-30 — the comment attributes a string message to "C++ subprocess errors" and an array to "R-side errors", but this PR makes the C++ backend always send an array. The comment describes removed behavior and could mislead a maintainer into deleting the defensive string branch, reintroducing the bug. Reframe to the live invariant + defensive intent (e.g. "normally an array; tolerate a bare string defensively so a malformed/legacy response renders rather than throwing on .join").

Suggestions

  1. src/cpp/session/modules/data/SessionData.cpp:131-137 — the generic "Operation finished with error code." is now always prepended ahead of stderr, and enhancePreviewErrorMessage (DataImport.java:195-217) prepends "Is this a valid CSV file? " on top, so a stderr-bearing failure reads "Is this a valid CSV file? Operation finished with error code. <real error>". Push the generic message only when errors_.empty() to keep the specific error while still guaranteeing a non-empty array.

  2. e2e/rstudio/tests/panes/environment/import_dataset.test.ts:54-66 — test.fixme moved inside the .catch() now throws before the cancel click, leaking the import dialog on Windows CI. Impact is largely absorbed by resetForNextTest's dismissAllModals (it logs a benign leaked-modal warning), but restoring cancel-before-skip keeps teardown clean.

  3. e2e/rstudio/tests/panes/environment/import_dataset.test.ts:54 — t.includes('error') is broad and case-sensitive (matches unrelated label copy; misses a capitalized "Error"). Key only on the precise 'valid CSV file' marker.

  4. src/gwt/.../dataimport/model/DataImportAssembleResponse.java:26-31 — identical getErrorMessage() logic now lives in both overlay types, but this one has no explanatory comment. Apply the (corrected) comment to both, or extract a shared static helper.

  5. PR description claims the test "re-checks for errors after the timeout in case they appeared asynchronously," but the diff does a single inline check inside the waitFor .catch() — no separate re-check. Correct the description.

@gtritchie gtritchie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Feedback posted

- add DataImportPreviewResponseTests covering string/array/missing shapes
- retarget e2e diagnostic to the top-level Error dialog; cancel before skip
- prefer captured stderr over the generic message in continuationWithError
- clarify the always-array invariant in the overlay getErrorMessage comments
@kevinushey
kevinushey merged commit 28f696e into main Jun 18, 2026
14 of 15 checks passed
@kevinushey
kevinushey deleted the bugfix/17985-import-preview-error-display branch June 18, 2026 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants