Skip to content

Fallback to md5sum when uname fails - #75

Merged
shcheklein merged 5 commits into
fsspec:mainfrom
AleksZyro:fallback-md5sum-checksum
Nov 29, 2026
Merged

shcheklein merged 5 commits into
fsspec:mainfrom
AleksZyro:fallback-md5sum-checksum

Conversation

@AleksZyro

@AleksZyro AleksZyro commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Refs #16.

checksum() currently calls uname before trying the checksum command. On servers where opening a shell session for uname fails, this prevents md5sum from being attempted even when it is available.

This falls back to the Linux md5sum path when uname cannot be executed.

Regression tests exercise the real _get_system path for both ChannelOpenError and ProcessError, check quoting of paths containing spaces, and verify that a failure of the fallback command still propagates.

Validation on Linux (WSL) / Python 3.11.17:

  • python -m pytest -q: 48 passed.
  • black --check tests/test_sshfs.py: passed (26.1.0).
  • isort --check-only tests/test_sshfs.py: passed (5.10.1).
  • git diff --check: passed.

The five focused fallback cases also pass on Windows. The full Windows run has seven failures, all reproduced on the previous PR head; the project CI targets Linux and macOS.

@codecov-commenter

codecov-commenter commented Aug 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.89%. Comparing base (15aac74) to head (f742844).
⚠️ Report is 30 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #75      +/-   ##
==========================================
+ Coverage   94.30%   97.89%   +3.58%     
==========================================
  Files          13       13              
  Lines         738     1138     +400     
==========================================
+ Hits          696     1114     +418     
+ Misses         42       24      -18     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a Linux md5sum fallback when remote system detection fails.

Changes:

  • Handles ChannelOpenError and ProcessError from uname.
  • Adds regression coverage for session failure fallback.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
sshfs/spec.py Implements checksum fallback logic.
tests/test_sshfs.py Tests fallback to md5sum.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@AleksZyro

Copy link
Copy Markdown
Contributor Author

Hi! I wanted to follow up and ask whether this PR is still useful and whether the fallback behaviour matches the project’s expectations. I’m happy to address any requested changes or update the tests if needed. Thanks for taking a look.

checksum on main now sends its command through _execute_with_paths,
caches uname, and handles names that need escaping, so the conflicts
are resolved by keeping main's checksum and wrapping only the
_get_system call in the uname fallback.

The tests called _checksum on a stand-in object, which no longer has
what _checksum uses. They now run against the mock server with uname
refused (ChannelOpenError) or failing (ProcessError), on a new instance
that hasn't cached uname yet, and check the checksum of a name with a
space and that a missing file still raises FileNotFoundError.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@shcheklein

Copy link
Copy Markdown
Collaborator

Thanks for your patience, and sorry it took this long to get back to you. Yes, this is still useful. Session request failed is what asyncssh raises when the server refuses the exec request for one command, which is how servers that allow only some commands reject uname while running md5sum, as in #16.

checksum changed a lot on main since you opened this: commands go through _execute_with_paths, uname is cached, and names that md5sum escapes are handled. So I merged main and kept only your fallback around _get_system.

The tests called _checksum on a stand-in object, which no longer has what _checksum uses. They now run against the mock server with uname refused (ChannelOpenError) or failing (ProcessError), on a new instance that hasn't cached uname yet. They check the checksum of a name with a space, and that a missing file still raises FileNotFoundError.

A refused uname isn't cached, so such servers still send one refused request per checksum. Caching the failure would make a temporary error, such as a session limit, stick for the instance's lifetime.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The fallback misses translated FileNotFoundError exceptions, and the regression tests depend on host-provided md5sum, causing failures on macOS installations that only provide md5.

2 open issues

Review effort: Balanced

Comment thread tests/test_sshfs.py Resolved
Comment thread sshfs/spec.py Resolved
wrap_exceptions turns a ProcessError whose message ends in "No such
file or directory" into FileNotFoundError, so that uname failure
skipped the md5sum fallback. The fallback tests now cover it, and they
skip when the machine that runs the mock server has no md5sum, as on
older macOS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The SSH checksum fallback change has no active review issues.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@shcheklein
shcheklein merged commit 70f00d1 into fsspec:main Nov 29, 2026
9 checks passed
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.

4 participants