Skip to content

fix(upload): flatten both path separators in the upload state file name - #1218

Merged
stevemessick merged 3 commits into
Kaggle:mainfrom
gopain185:fix/upload-state-path-separators
Oct 23, 2026
Merged

stevemessick merged 3 commits into
Kaggle:mainfrom
gopain185:fix/upload-state-path-separators

Conversation

@gopain185

Copy link
Copy Markdown
Contributor

On Windows, kaggle datasets create / kaggle datasets version (and any other command that uses resumable uploads) fails when the folder path is written with forward slashes, for example from Git Bash:

$ kaggle datasets version -p C:/Users/me/work/my-dataset -m "update"
[Errno 2] No such file or directory: 'C:\Users\me\AppData\Local\Temp\.kaggle/uploads\C_/Users/me/work/my-dataset/README.md.json'

Cause. ResumableUploadContext.get_upload_info_file_path() flattens the uploaded file's path into a state-file name with path.replace(os.path.sep, "_"). On Windows os.path.sep is \, so / survives, and the name points into sub-directories of the state dir that do not exist. A relative -p path happens to work because the paths below the folder are built with os.path.join.

Fix. Replace \, / and : alike (re.sub(r"[\\/:]", "_", path)), so the state file is always a single file directly inside the state dir. On POSIX, \ is a legal file-name character, so the only effect there is a different name for the temporary state file.

The state-file name changes for such paths, so an upload interrupted before upgrading restarts instead of resuming. On Windows those uploads could not save their state anyway.

Tests. I added TestUploadInfoFilePath to tests/unit/test_upload_helpers.py. It covers Windows paths with /, \ and mixed separators, POSIX paths and relative paths, and it writes a state file for a forward-slash Windows path. On the current main, 4 sub-cases and the write test fail; with the fix, all pass.

I ran tests/unit on Windows (Python 3.13). The only failure is the existing test_symlinked_state_dir_is_rejected, which fails on unpatched main too, because creating a symlink there needs a privilege (WinError 1314).

I also added a line to the ### Next section of the CHANGELOG.

ResumableUploadContext.get_upload_info_file_path() turns the path of the
file being uploaded into a file name inside the upload state directory.
It only replaced os.path.sep, which is "\" on Windows, so a path written
with forward slashes (C:/data/train.csv, as produced by Git Bash, MSYS or
Path.as_posix()) kept its "/" and pointed into sub-directories of the
state dir that do not exist. Saving the state then failed with
"[Errno 2] No such file or directory" and the upload aborted.

Replace "\", "/" and ":" alike, and add tests for Windows, POSIX and
relative paths.
@sridipbasu

Copy link
Copy Markdown
Collaborator

Tested locally and LGTM!

@sridipbasu sridipbasu added the bug Something isn't working label Oct 15, 2026
@stevemessick

Copy link
Copy Markdown
Contributor

/gcbrun

@stevemessick stevemessick left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

@stevemessick

Copy link
Copy Markdown
Contributor

/gcbrun

@stevemessick
stevemessick merged commit 8b88a6a into Kaggle:main Oct 23, 2026
12 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.

3 participants