FIX: rclone - directory listing broken by rclone log messages - #47
Open
miklos-szel wants to merge 2 commits into
Open
FIX: rclone - directory listing broken by rclone log messages#47miklos-szel wants to merge 2 commits into
miklos-szel wants to merge 2 commits into
Conversation
rclone writes log messages to stderr, e.g. the SFTP backend notice
NOTICE: het: No host key validation is being performed.
Set known_hosts_file to enable it.
but RunCommand ran the child process with poStderrToOutPut, so those
lines were prepended to the stdout of "lsjson". The resulting text is
not valid JSON, GetJSON raised an exception, ParseLsJson swallowed it
and returned an empty list, and FsFindFirstW ended up reporting an
empty/unreadable directory.
Capture stdout and stderr on separate pipes instead, draining both in
one loop so neither pipe buffer can fill up and block the child. As a
side effect LastError now holds the actual rclone error message rather
than a mix of both streams.
RunCommandWithProgress keeps poStderrToOutPut on purpose, that is where
--progress writes its output.
Also make the parsers tolerant of unexpected output: ParseLsJson skips
anything printed before the JSON array, and ParseListRemotes only
accepts lines ending with a colon, which is the format listremotes
prints.
miklos-szel
force-pushed
the
wfx_rclone_stderr
branch
from
August 13, 2026 11:46
f55c849 to
3395d46
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Browsing any remote that makes rclone emit a log message fails - the panel shows an empty or unreadable directory. Easiest way to reproduce is an SFTP remote without
known_hosts_file:Cause
That notice goes to stderr, but
TRcloneCli.RunCommandran the child process withpoStderrToOutPut, so the log lines were prepended to the stdout oflsjson. The result is not valid JSON,GetJSONraises,ParseLsJsonswallows the exception and returns an empty list, andFsFindFirstWreports an empty directory.Fix
Capture stdout and stderr on separate pipes, draining both in a single loop so neither pipe buffer can fill up and block the child process.
LastErrornow carries the actual rclone error message instead of a mix of both streams.RunCommandWithProgresskeepspoStderrToOutPuton purpose - that is where--progresswrites.Additionally the parsers are made tolerant of unexpected output, so a stray line can never silently blank a listing again:
ParseLsJsonskips anything printed before the JSON array.ParseListRemotesonly accepts lines ending with a colon, which is the formatlistremotesprints.Testing
Tested on macOS against an SFTP remote that triggers the notice: listing, entering directories, and
listremotesat the root all work again.