Skip to content

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

Open
zyratlo wants to merge 3 commits into
apache:mainfrom
zyratlo:migration-tool-language-error-msgs
Open

zyratlo wants to merge 3 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

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.57%. Comparing base (7f9bdf3) to head (c60bf12).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #9578   +/-   ##
=========================================
  Coverage     91.57%   91.57%           
  Complexity     5158     5158           
=========================================
  Files          1300     1300           
  Lines         58092    58131   +39     
  Branches       7615     7626   +11     
=========================================
+ Hits          53195    53235   +40     
  Misses         2959     2959           
+ Partials       1938     1937    -1     
Flag Coverage Δ *Carryforward flag
access-control-service 77.44% <ø> (ø) Carriedforward from 7f9bdf3
agent-service 99.56% <ø> (ø) Carriedforward from 7f9bdf3
amber 85.43% <ø> (ø) Carriedforward from 7f9bdf3
computing-unit-managing-service 63.88% <ø> (ø) Carriedforward from 7f9bdf3
config-service 87.50% <ø> (ø) Carriedforward from 7f9bdf3
file-service 82.16% <ø> (ø) Carriedforward from 7f9bdf3
frontend 96.46% <100.00%> (+<0.01%) ⬆️
notebook-migration-service 83.77% <ø> (ø) Carriedforward from 7f9bdf3
pyamber 98.38% <ø> (ø) Carriedforward from 7f9bdf3
result-service 85.71% <ø> (ø) Carriedforward from 7f9bdf3
workflow-compiling-service 78.30% <ø> (ø) Carriedforward from 7f9bdf3

*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.

This branch has not been deployed

No deployments
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

2 participants