Skip to content

Commit

Permalink
BF: annexrepo: Error when using broken 'find --json'
Browse files Browse the repository at this point in the history
On git-annex 7.20190626, 'find --json' produces regular output rather
than json.  In addition to being broken, this is problematic because,
before the previous commit, we silently dropped lines that didn't
start with "{".  In the case of 'datalad get', this led to us
incorrectly claiming that an absent file was present.

We now fail with a RuntimeError in this situation, but let's raise a
more informative error when 'find --json' is used with git-annex
7.20190626.

This has been fixed in b8ef1bf3b (Fix find --json to output json once
more, 2019-07-05).

Re: http://git-annex.branchable.com/bugs/Regression_in___96__find_--json__96___output/
Re: #3510 (comment)
Closes #3513.
  • Loading branch information
kyleam committed Jul 8, 2019
1 parent fe3c6df commit 0863ca8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions datalad/support/annexrepo.py
Expand Up @@ -81,6 +81,7 @@
from .exceptions import InsufficientArgumentsError
from .exceptions import OutOfSpaceError
from .exceptions import RemoteNotAvailableError
from .exceptions import BrokenExternalDependency
from .exceptions import OutdatedExternalDependency
from .exceptions import MissingExternalDependency
from .exceptions import IncompleteResultsError
Expand Down Expand Up @@ -2541,9 +2542,17 @@ def _run_annex_command_json(self, command,
lgr.warning("Received non-json lines for --json command: %s",
others)
else:
raise RuntimeError(
"Received no json output for --json command, only:\n{}"
.format(" ".join(others)))
annex_ver = external_versions['cmd:annex']
if annex_ver == "7.20190626" and command == "find":
# TODO: Drop this once GIT_ANNEX_MIN_VERSION is over
# 7.20190626.
exc = BrokenExternalDependency(
"find --json output is broken on git-annex 7.20190626")
else:
exc = RuntimeError(
"Received no json output for --json command, only:\n{}"
.format(" ".join(others)))
raise exc
return json_objects

# TODO: reconsider having any magic at all and maybe just return a list/dict always
Expand Down

0 comments on commit 0863ca8

Please sign in to comment.