Skip to content

feat(notebook-migration): reject uploads whose language does not match the selected tab - #9578

Merged
mengw15 merged 8 commits into
apache:mainfrom
zyratlo:migration-tool-language-error-msgs
Nov 24, 2026
Merged

mengw15 merged 8 commits into
apache:mainfrom
zyratlo:migration-tool-language-error-msgs

Conversation

@zyratlo

@zyratlo zyratlo commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • Notebooks: the language comes from metadata.kernelspec.language, falling back to metadata.language_info.name, ignoring case and surrounding spaces. A notebook that declares neither is accepted as before.
  • Files: the extension decides. An extension no language claims keeps today's upload hint.
  • Folders: a folder with no files in the selected language but some in another is pointed at the right tab. Any other folder, including a mixed one, goes on to parseFolder and its existing checks.
Upload Message
R notebook as a Python Notebook This notebook uses an R kernel, not Python. Switch the notebook type to R Notebook.
Python notebook as an R Notebook This notebook uses a Python kernel, not R. Switch the notebook type to Python Notebook.
Any other kernel, either type This notebook uses a julia kernel. Only Python and R notebooks can be converted.
R file on a Python tab This is an R file. Upload it under the R File tab.
Python file on an R tab This is a Python file. Upload it under the Python File tab.
Python folder on R Folder This folder holds Python files, not R. Upload it under the Python Folder tab.
R folder on Python Folder This folder holds R files, not Python. Upload it under the R Folder tab.

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. parseScriptFile takes 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, the language_info fallback, 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 reaching parseFolder. 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 from parseScriptFile.

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)

@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • No candidates found from git blame history.

@zyratlo

zyratlo commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

/request-review @mengw15

@github-actions
github-actions Bot requested a review from mengw15 November 20, 2026 22:17
@codecov-commenter

codecov-commenter commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.66%. Comparing base (607a96c) to head (b399c20).
✅ All tests successful. No failed tests found.

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     
Flag Coverage Δ *Carryforward flag
access-control-service 77.44% <ø> (ø) Carriedforward from 4a537f0
agent-service 99.56% <ø> (ø) Carriedforward from 4a537f0
amber 85.53% <ø> (-0.25%) ⬇️ Carriedforward from 4a537f0
computing-unit-managing-service 63.83% <ø> (ø) Carriedforward from 4a537f0
config-service 87.50% <ø> (ø) Carriedforward from 4a537f0
file-service 82.16% <ø> (ø) Carriedforward from 4a537f0
frontend 96.43% <100.00%> (+<0.01%) ⬆️
notebook-migration-service 83.77% <ø> (ø) Carriedforward from 4a537f0
pyamber 98.38% <ø> (-0.01%) ⬇️ Carriedforward from 4a537f0
result-service 85.71% <ø> (-0.78%) ⬇️ Carriedforward from 4a537f0
workflow-compiling-service 78.30% <ø> (-2.60%) ⬇️ Carriedforward from 4a537f0

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Malformed notebook metadata can throw during import and bypass error handling, leaving the modal’s close, Escape, and backdrop controls disabled.

1 open issue
1 resolved since last review

Review effort: Balanced

@mengw15 mengw15 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@mengw15
mengw15 enabled auto-merge November 22, 2026 12:28
@mengw15
mengw15 added this pull request to the merge queue Nov 23, 2026
Merged via the queue into apache:main with commit 3ed0146 Nov 24, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Notebook Migration] Reject uploads whose language does not match the selected import tab

4 participants