Skip to content

Conversation

@JCapul
Copy link
Contributor

@JCapul JCapul commented Oct 9, 2025

Hi, I hit the issue of not being able to open a ZIP file in JupyterLite due to a binary-to-text corruption at some point. I dug into the code base and I think I managed to fix it (at least it works on my machine 😄).

Thanks ahead for your review!

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2025

lite-badge 👈 Try it on ReadTheDocs

@JCapul JCapul marked this pull request as ready for review October 9, 2025 15:35
Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

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

Damn, I knew this would come to me at some point, when I wrote that code I knew video and audio files wouldn't be enough 🫣 Thanks a lot!

src/drive.ts Outdated
Comment on lines 386 to 391
if (
[
'application/zip',
'application/pdf',
'application/octet-stream'
].includes(file.type)
Copy link
Member

Choose a reason for hiding this comment

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

Since this is a condition for using "base64", would you mind extending the if condition that's above with your new condition?

Copy link
Member

Choose a reason for hiding this comment

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

Long term we'd need some better way to do this, maybe there is some place in jupyter-server where they decide depending on the extension or mimetype whether it should be sent to the front-end in base64 or something else.

Not asking you to figure it out in this PR, but if you do that's great!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here you go. Pushed on new commit that groups all base64 conditions together.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

base64 is always safe but it incurs some overhead especially for large text files like CSV. Maybe a safer way would be to reverse the check by explicitly specifying the types that should be treated as text, and defaulting to binary hence base64 format. Maybe the type starting by "text/" + "application/json" would cover a lot of cases.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! The CI failures are most likely unrelated. The CI may have been broken since some time.

@martinRenou martinRenou added the bug Something isn't working label Oct 10, 2025
@martinRenou martinRenou merged commit 5b0857f into jupyterlab-contrib:main Oct 10, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants