Repository navigation
feat(notebook-migration): reject uploads whose language does not match the selected tab - #9578
Conversation
Automated Reviewer SuggestionsBased on the
|
|
/request-review @mengw15 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9578 +/- ##
============================================
- Coverage 91.68% 91.66% -0.02%
+ Complexity 5139 5064 -75
============================================
Files 1304 1302 -2
Lines 58157 57470 -687
Branches 7587 7538 -49
============================================
- Hits 53319 52680 -639
+ Misses 2930 2894 -36
+ Partials 1908 1896 -12
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
Empty or whitespace-only kernelspec language values suppress the language-info fallback, causing R notebooks to receive Python prompts or supported notebooks to trigger unsupported-kernel errors.
1 open issue
What changed in this PR
This PR adds language-mismatch checks to Texera’s notebook migration import flow, helping prevent uploads from reaching the wrong conversion prompts.
Changes:
- Validates notebook metadata, file extensions, and folder contents against the selected language, with guidance that respects R availability.
- Makes script read errors language-specific and extends migration error notifications to 8 seconds.
- Adds regression tests for mismatch handling and updates existing error assertions.
| File | Description |
|---|---|
frontend/src/app/workspace/service/notebook-migration/notebook-migration.service.ts |
Uses the selected language in script read errors. |
frontend/src/app/workspace/service/notebook-migration/notebook-migration.service.spec.ts |
Checks exact Python and R script error messages. |
frontend/src/app/workspace/service/notebook-migration/migration-llm.ts |
Exports shared language display names. |
frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.ts |
Adds mismatch validation, corrective guidance, and longer migration notifications. |
frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.spec.ts |
Covers mismatch cases, language dispatch, and notification duration. |
Review effort: Balanced
…ec language is blank

What changes were proposed in this PR?
The import modal decides which prompts a conversion uses from where the user uploads: the Python Notebook / R Notebook switch on the Jupyter Notebook tab, or the Python File, Python Folder, R File and R Folder tabs. Until now only one mismatch was checked, and its message could point users to the wrong place. An R notebook uploaded as a Python Notebook went through to the Python prompts and came back as a workflow of broken Python UDFs.
Mismatch checks. The dashboard now checks every upload against the selected language before any model call:
metadata.kernelspec.language, falling back tometadata.language_info.name, ignoring case and surrounding spaces. A notebook that declares neither is accepted as before.parseFolderand its existing checks.When the right place is an R option and R is not enabled on the deployment, the message says so instead of pointing at a disabled control, for example "This notebook uses an R kernel, and R is not enabled on this deployment." The checks are driven by the per language table the dispatch already used, now extended with each language's kernel name, notebook type and tab names, so a later language gets them without new branches.
Script read errors.
parseScriptFiletakes the language, so an empty or unreadable R file is reported as "The R file is empty." or "Failed to read the R file." rather than naming Python.Error duration. Migration errors now stay on screen for 8 seconds instead of ng-zorro's default 3, since most of them are two sentences of instructions. Errors elsewhere in the app keep the default.
Demo video
https://drive.google.com/file/d/1BkMJHuZqcvIPArxia73Dtqp3th-_y2kn/view?usp=sharing
Any related issues, documentation, discussions?
Closes #8929
Parent-issue #4301
How was this PR tested?
user-workflow.component.spec.ts, a new "language mismatches" block of 14 tests covering every row above: R and Python notebooks on the wrong type with R on and off, case and spacing in the declared language, thelanguage_infofallback, an unsupported kernel on both types with the right article, R and Python files on the wrong tab with R on and off, an unknown extension, folders in either direction with R on and off, and a mixed folder and a folder with no source both reachingparseFolder. Existing assertions were updated to the new wording and to expect the 8 second duration, and the R folder test from feat(notebook-migration): add r folders to the import modal #9427 now sends R files.notebook-migration.service.spec.ts: the exact Python and R messages fromparseScriptFile.The full frontend suite passes, and every new line and branch is covered.
Checked against a local stack by driving the modal's own upload and submit with files carrying the mock inputs' kernels, extensions and folder paths. With R off, the four R uploads on Python options each showed the R is not enabled message. With R on, all seven mismatches showed the messages above, and a matching R notebook passed the checks and went on to the model call. No mismatch made a model request. An error toast stayed visible for about 9 seconds, the 8 second duration plus its fade out.
Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 5.5)