diff options
author | Nick Vatamaniuc <vatamane@apache.org> | 2019-10-24 14:30:01 -0400 |
---|---|---|
committer | Nick Vatamaniuc <nickva@users.noreply.github.com> | 2019-10-24 14:38:28 -0400 |
commit | 3ded0e5a0b503289937bb9db7a40fd18f0810d3d (patch) | |
tree | 46abd90a3d3044975ab379684b67c1cc063ea583 | |
parent | 5334997ab5bf4282b2a560caa61fcf44ff784043 (diff) | |
download | couchdb-3ded0e5a0b503289937bb9db7a40fd18f0810d3d.tar.gz |
Add a special error for an invalid legacy local doc revsion
Since we are dealing with upgrades and both versions start out as binaries,
make sure we add extra belts and suspenders to surface any issues with encoding
errors.
-rw-r--r-- | src/fabric/src/fabric2_fdb.erl | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl index dc803115f..c59346ebd 100644 --- a/src/fabric/src/fabric2_fdb.erl +++ b/src/fabric/src/fabric2_fdb.erl @@ -532,8 +532,13 @@ get_local_doc_rev(_Db0, <<?LOCAL_DOC_PREFIX, _/binary>> = DocId, Val) -> case Val of <<131, _/binary>> -> % Compatibility clause for an older encoding format - {Rev, _} = binary_to_term(Val, [safe]), - Rev; + try binary_to_term(Val, [safe]) of + {Rev, _} -> Rev; + _ -> erlang:error({invalid_local_doc_rev, DocId, Val}) + catch + error:badarg -> + erlang:error({invalid_local_doc_rev, DocId, Val}) + end; <<_/binary>> -> try binary_to_integer(Val) of IntVal when IntVal >= 0 -> |