Spot check crashes #968
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What I'm trying to do and why
I tried adding
spotchecks like this:Steps to reproduce
borgmatic check -v2 --only spot --progress -nActual behavior
Expected behavior
Passing the
spotcheck without errorOther notes / implementation ideas
I've added logging with
import traceback:I've dumped the output from
borgmatic.borg.list.capture_archive_listingto the console withpprint:So I'm guessing that this output of varying types is what causes the problem.
borgmatic version
1.9.5
borgmatic installation method
pacman
Borg version
1.4.0
Python version
No response
Database version (if applicable)
3.13.1
Operating system and version
Arch Linux
Thanks for filing this—and for all the debugging! Can I get a look at your
pprintstatements? I'm having a hard time understanding what that output even means! For instance, if that third output line was really a tuple instead of a string, I'd expectpprintto put a comma somewhere in there...Here's what I've added (apart from the
import pprintstatement):In
actions/check.py, line 430:I'm still at a bit of a loss as to what's going on here. In addition to the
pprint(), would you mind doing aprint(type(line))as well? I can't figure out what kind of data would even result in thepprintoutput you included.Also, what version of Python are you using? Thanks.
Aha, I think I figured out at least part of it. (You can skip the
type()thing unless you'd like to verify...) I'm guessing that all the lines are actually strings, and, confusingly, the variedpprintoutput is what happens with super long lines vs. shorter lines. You can reproduce that behavior yourself just in an interactive Python session bypprinting a long line starting with "d " (note the space) vs. a short line that starts with "d ".So another debugging thing you can do.. Right after your
pprint(), try adding apprint(line.split(' ', 1)). That will hopefully show us the line that triggers the error.In short: The crash seems to be caused by a line break in the file name.
Sorry for making it more compilcated, I was not aware of
pprint's behaviour.Python version is 3.13.1
I've included the
pprintStatements you suggested, and also forced the code to crash immediately once it encounters an invalidline:Here's
stat's output:And what Python reads with
os.listdir():Ah, excellent sleuthing! A filename containing a newline would definitely make sense as to the cause here. I'll see what I can do about it. It may be a little tough because the Borg output is newline-separated....
Okay, this is fixed in main and will be part of the next release! I instructed Borg to separate filenames in the listing with null characters instead of newlines. That allows borgmatic to consume filenames that contain newlines when doing the spot check. Thanks again!
Released in borgmatic 1.9.7!
Be aware of this related bug and fix as well: #981.