mirror of https://gitee.com/bigwinds/arangodb
Change undocumented behaviour in case of invalid rev in If-Match headers.
An invalid rev should lead to a 412 PRECONDITION FAILED rather than a 404 BAD error. This is more intuitive, in particular since we have never documented what valid rev strings are. Also adjust tests and CHANGELOG.
This commit is contained in:
parent
db9c244266
commit
cbcda7932c
|
@ -1,6 +1,9 @@
|
|||
devel
|
||||
-----
|
||||
|
||||
* change undocumented behaviour in case of invalid revision ids in
|
||||
If-Match and If-None-Match headers from 400 (BAD) to 412 (PRECONDITION
|
||||
FAILED).
|
||||
|
||||
v3.2.alpha1 (2017-02-05)
|
||||
------------------------
|
||||
|
|
|
@ -190,20 +190,20 @@ describe ArangoDB do
|
|||
hdr = { "if-match" => "\"*abcd\"" }
|
||||
doc = ArangoDB.log_delete("#{prefix}-rev-invalid", cmd, :headers => hdr )
|
||||
|
||||
doc.code.should eq(400)
|
||||
doc.code.should eq(412)
|
||||
doc.parsed_response['error'].should eq(true)
|
||||
doc.parsed_response['errorNum'].should eq(400)
|
||||
doc.parsed_response['code'].should eq(400)
|
||||
doc.parsed_response['errorNum'].should eq(1200)
|
||||
doc.parsed_response['code'].should eq(412)
|
||||
|
||||
# delete document, invalid revision
|
||||
cmd = "/_api/document/#{did}"
|
||||
hdr = { "if-match" => "'*abcd'" }
|
||||
doc = ArangoDB.log_delete("#{prefix}-rev-invalid", cmd, :headers => hdr)
|
||||
|
||||
doc.code.should eq(400)
|
||||
doc.code.should eq(412)
|
||||
doc.parsed_response['error'].should eq(true)
|
||||
doc.parsed_response['errorNum'].should eq(400)
|
||||
doc.parsed_response['code'].should eq(400)
|
||||
doc.parsed_response['errorNum'].should eq(1200)
|
||||
doc.parsed_response['code'].should eq(412)
|
||||
|
||||
# delete document, correct revision
|
||||
cmd = "/_api/document/#{did}"
|
||||
|
|
|
@ -567,7 +567,7 @@ describe ArangoDB do
|
|||
hdr = { "if-match" => "'*abcd'" }
|
||||
doc = ArangoDB.log_head("#{prefix}-head-rev-invalid", cmd, :headers => hdr)
|
||||
|
||||
doc.code.should eq(400)
|
||||
doc.code.should eq(412)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -266,20 +266,20 @@ describe ArangoDB do
|
|||
hdr = { "if-match" => "\"*abcd\"" }
|
||||
doc = ArangoDB.log_put("#{prefix}-rev-invalid", cmd, :headers => hdr, :body => body)
|
||||
|
||||
doc.code.should eq(400)
|
||||
doc.code.should eq(412)
|
||||
doc.parsed_response['error'].should eq(true)
|
||||
doc.parsed_response['errorNum'].should eq(400)
|
||||
doc.parsed_response['code'].should eq(400)
|
||||
doc.parsed_response['errorNum'].should eq(1200)
|
||||
doc.parsed_response['code'].should eq(412)
|
||||
|
||||
# update document, invalid revision
|
||||
cmd = "/_api/document/#{did}"
|
||||
hdr = { "if-match" => "'*abcd'" }
|
||||
doc = ArangoDB.log_put("#{prefix}-rev-invalid", cmd, :headers => hdr, :body => body)
|
||||
|
||||
doc.code.should eq(400)
|
||||
doc.code.should eq(412)
|
||||
doc.parsed_response['error'].should eq(true)
|
||||
doc.parsed_response['errorNum'].should eq(400)
|
||||
doc.parsed_response['code'].should eq(400)
|
||||
doc.parsed_response['errorNum'].should eq(1200)
|
||||
doc.parsed_response['code'].should eq(412)
|
||||
|
||||
# update document, correct revision
|
||||
cmd = "/_api/document/#{did}"
|
||||
|
|
|
@ -203,23 +203,19 @@ bool RestDocumentHandler::readSingleDocument(bool generateBody) {
|
|||
|
||||
// check for an etag
|
||||
bool isValidRevision;
|
||||
TRI_voc_rid_t const ifNoneRid =
|
||||
TRI_voc_rid_t ifNoneRid =
|
||||
extractRevision("if-none-match", isValidRevision);
|
||||
if (!isValidRevision) {
|
||||
generateError(rest::ResponseCode::BAD,
|
||||
TRI_ERROR_HTTP_BAD_PARAMETER, "invalid revision number");
|
||||
return false;
|
||||
ifNoneRid = 1; // an impossible rev, so precondition failed will happen
|
||||
}
|
||||
|
||||
OperationOptions options;
|
||||
options.ignoreRevs = true;
|
||||
|
||||
TRI_voc_rid_t const ifRid =
|
||||
TRI_voc_rid_t ifRid =
|
||||
extractRevision("if-match", isValidRevision);
|
||||
if (!isValidRevision) {
|
||||
generateError(rest::ResponseCode::BAD,
|
||||
TRI_ERROR_HTTP_BAD_PARAMETER, "invalid revision number");
|
||||
return false;
|
||||
ifRid = 1; // an impossible rev, so precondition failed will happen
|
||||
}
|
||||
|
||||
VPackBuilder builder;
|
||||
|
@ -396,9 +392,7 @@ bool RestDocumentHandler::modifyDocument(bool isPatch) {
|
|||
bool isValidRevision;
|
||||
revision = extractRevision("if-match", isValidRevision);
|
||||
if (!isValidRevision) {
|
||||
generateError(rest::ResponseCode::BAD,
|
||||
TRI_ERROR_HTTP_BAD_PARAMETER, "invalid revision number");
|
||||
return false;
|
||||
revision = 1; // an impossible revision, so precondition failed
|
||||
}
|
||||
VPackSlice keyInBody = body.get(StaticStrings::KeyString);
|
||||
if ((revision != 0 && TRI_ExtractRevisionId(body) != revision) ||
|
||||
|
@ -502,9 +496,7 @@ bool RestDocumentHandler::deleteDocument() {
|
|||
bool isValidRevision = false;
|
||||
revision = extractRevision("if-match", isValidRevision);
|
||||
if (!isValidRevision) {
|
||||
generateError(rest::ResponseCode::BAD,
|
||||
TRI_ERROR_HTTP_BAD_PARAMETER, "invalid revision number");
|
||||
return false;
|
||||
revision = 1; // an impossible revision, so precondition failed
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue