You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2019/10/24 18:33:50 UTC
[couchdb] branch add-extra-suspenders-to-local-doc-revs created
(now 0607536)
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a change to branch add-extra-suspenders-to-local-doc-revs
in repository https://gitbox.apache.org/repos/asf/couchdb.git.
at 0607536 Add a special error for an invalid legacy local doc revsion
This branch includes the following new commits:
new 0607536 Add a special error for an invalid legacy local doc revsion
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[couchdb] 01/01: Add a special error for an invalid legacy local
doc revsion
Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch add-extra-suspenders-to-local-doc-revs
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 06075361f53012e678141e9ac2eb8202b296fb9c
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Thu Oct 24 14:30:01 2019 -0400
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.
---
src/fabric/src/fabric2_fdb.erl | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl
index dc80311..c59346e 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 ->