[ZEPPELIN-6634] Download service prepends a UTF-8 BOM to JSON files, breaking standard parsers - #5449
Open
xhaktm00 wants to merge 1 commit into
Open
[ZEPPELIN-6634] Download service prepends a UTF-8 BOM to JSON files, breaking standard parsers#5449xhaktm00 wants to merge 1 commit into
xhaktm00 wants to merge 1 commit into
Conversation
Downloaded zpln and ipynb files start with a UTF-8 BOM, which the JSON specification does not allow, so strict parsers refuse them: Python's json reports an unexpected BOM and nbformat reports the notebook is not JSON. Zeppelin reads its own files back because Gson skips the BOM, which is why this went unnoticed until a downloaded ipynb was opened in Jupyter. The BOM was added in ZEPPELIN-672 so Excel reads a CSV export as UTF-8, but it lives in the shared download service, so the zpln and ipynb exports that later reused the service inherited it. Let the call site decide instead. Only the CSV and TSV export asks for a BOM; the JSON exports leave it off. The new UI has no caller that needs one, since its CSV and TSV export goes through the xlsx library.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this PR for?
Downloaded
.zplnand.ipynbfiles start with a UTF-8 BOM, which the JSON specification does not allow, so strict parsers refuse them:Zeppelin reads its own files back because Gson tolerates the BOM, which is why this went unnoticed until a downloaded
.ipynbwas opened in Jupyter.The BOM was added in ZEPPELIN-672 so Excel reads a CSV export as UTF-8, but it lives in the shared download service, so the
zplnandipynbexports that later reused that service inherited it.This makes the caller decide:
saveAs()takes abomflag defaulting tofalse, and only the CSV/TSV call site passestrue. Of the six call sites, that is the only one that needs it — the new UI has none at all, since its CSV/TSV export goes through thexlsxlibrary.result.controller.jsnotebook.controller.js(x2)websocket-event.factory.jsaction-bar.component.ts(x2)Both UIs are fixed together, and the classic service drops the BOM in both its IE and standard branches.
What type of PR is it?
Bug Fix
Todos
bomflag to bothsaveAs()services, defaulting to offWhat is the Jira issue?
How should this be tested?
New spec
save-as.service.spec.tschecks the raw bytes handed tocreateObjectURL, sinceBlob.text()decodes and strips a leading BOM: azplnexport has no BOM and parses as JSON, and a CSV export withbom: truekeepsEF BB BF.Result:
Tests 31 passed (31).Manual, on a built server: export a note as
.zplnand download a table result as CSV.The zpln no longer starts with a BOM and Python parses it, while the CSV still carries one. Korean, Chinese and emoji survived in both.
Screenshots (if appropriate)
N/A
Questions: