Skip to content

[ZEPPELIN-5989] Resolve a local notebook dir as a file path instead of parsing it as a URI - #5518

Open
dev-donghwan wants to merge 1 commit into
apache:masterfrom
dev-donghwan:ZEPPELIN-5989
Open

dev-donghwan wants to merge 1 commit into
apache:masterfrom
dev-donghwan:ZEPPELIN-5989

Conversation

@dev-donghwan

Copy link
Copy Markdown
Contributor

What is this PR for?

VFSNotebookRepo.setNotebookDirectory() parses the notebook dir with new URI() unless it is a Windows absolute path like C:\.... A local path is not a URI and can contain characters that a URI does not allow:

  • On Windows the default dir is built as ./ + \ + notebook, so the server fails to start with URISyntaxException: Illegal character in path at index 2: ./\notebook.
  • On any OS, a dir with a space, like /home/me/My Notebooks, fails the same way.

The issue suggests joining the dir with Paths.get, but on Windows that gives .\notebook, which new URI() rejects too.

This PR:

  • Resolves a notebook dir without a scheme as a file path, new File(getAbsoluteDir(path)).toURI(), and parses only a dir with a scheme as a URI. The branch that handled a URI without a scheme is removed, since that case no longer reaches it.
  • Keeps rootNotebookFolder as a decoded path for a local dir. It was the root's URI with file:/// replaced, so it kept %20 for a space. list() strips it from note file names that are decoded since ZEPPELIN-6202, which would shift note paths by two characters per space, and GitNotebookRepo opens the repository at rootNotebookFolder/.git, which would be a different directory. list() now resolves the root by its URI instead of by this path. A dir with another scheme keeps its current value.

For a local dir without such characters, both values are the same as before.

I could not run it on Windows. On other systems the same code path is reached with a space, and Commons VFS treats a backslash in the file URI as a separator. It would help if someone on Windows could start the server from this branch without a configuration file, which is how the issue reproduces it.

What type of PR is it?

Bug Fix

What is the Jira issue?

How should this be tested?

  • VFSNotebookRepoTest.testNotebookDirWithCharactersThatAUriDoesNotAllow uses a dir with a space and one with a backslash, saves and lists a note, and checks its path.
  • GitNotebookRepoTest.notebookDirWithSpace checks that .git is created in the dir with a space and that a checkpoint is recorded.

Without the first change both tests fail with the URISyntaxException above; without the second the path and .git checks fail.

Run locally: VFSNotebookRepoTest (8), GitNotebookRepoTest (12), NotebookRepoSyncTest (10), NotebookServiceTest (13), NotebookServiceRaceConditionTest (1), NoteManagerMoveResaveRaceTest (1), NotebookTest (42). testSchedule, testScheduleDisabledWithName and testSchedulePoolUsage fail locally with and without this change: they wait five seconds for the cron run, and the interpreter process here takes about six seconds to sync its libraries and register.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant