notebook: Bug when renaming file (notebook 6.4.12)

Describe the bug In notebook 6.4.12,we cannot rename file sometimes.

To Reproduce Steps to reproduce the behavior:

  1. Install notebook 6.4.12
  2. Start notebook with root_dir="/home/foobar"
  3. Create a directory named abc (or any name with length len(root_dir) - len("Untitled") - 1)
  4. Create a notebook with default filename ‘Untitled.ipynb’
  5. Rename the notebook to any other filename

Then you should got the error message

File "/home/xxxxxxx/.miniconda3/lib/python3.8/site-packages/notebook/services/contents/filemanager.py",
line 579, in rename_file raise web.HTTPError(400, f'Cannot rename hidden file or directory {os_path!r}')
NameError: name 'os_path' is not defined

Expected behavior

Rename the file successfully.

According to the error message, I found a typo here (os_path is not defined, it should be old_path). .https://github.com/jupyter/notebook/blob/3e5b767ddbc3526729cadbc69fe472ffc3ec2e7e/notebook/services/contents/filemanager.py#L578-L579 And I notice that the result of is_hidden(old_path, self.root_dir) is true, this is because the result of "abc/Untitled.ipynb"[len("/home/foobar"):] is .ipynb and it is treated as a hidden file.

It seems that this bug is introduced by this commit https://github.com/jupyter/notebook/commit/f69eb96cff7149b38bca068f4b7faaa7baf55902 .

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 9
  • Comments: 15 (2 by maintainers)

Most upvoted comments

notebook/services/contents/filemanager.py

There is an error on this file rename function (line 500+)

The only way how to solve this situation is to downgrade…

pip3 install --upgrade notebook==“6.4.11”