Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return 404 if document type does not exist #33330

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,10 @@ private static Response.Outcome toOutcome(Reply reply) {
if (reply.getErrorCodes().contains(DocumentProtocol.ERROR_TEST_AND_SET_CONDITION_FAILED))
return CONDITION_FAILED;
if ( reply instanceof UpdateDocumentReply && ! ((UpdateDocumentReply) reply).wasFound()
|| reply instanceof RemoveDocumentReply && ! ((RemoveDocumentReply) reply).wasFound())
|| reply instanceof RemoveDocumentReply && ! ((RemoveDocumentReply) reply).wasFound()
|| reply.getErrorCodes().contains(DocumentProtocol.ERROR_DOCUMENT_NOT_FOUND)) {
return NOT_FOUND;
}
if (reply.getErrorCodes().contains(ErrorCode.TIMEOUT))
return TIMEOUT;
return ERROR;
Expand Down
4 changes: 2 additions & 2 deletions storage/src/tests/storageserver/communicationmanagertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ TEST_F(CommunicationManagerTest, unmapped_bucket_space_documentapi_request_retur
ASSERT_EQ(1, f.reply_handler.replies.size());
auto& reply = *f.reply_handler.replies[0];
ASSERT_TRUE(reply.hasErrors());
EXPECT_EQ(static_cast<uint32_t>(api::ReturnCode::REJECTED), reply.getError(0).getCode());
EXPECT_EQ(static_cast<uint32_t>(documentapi::DocumentProtocol::ERROR_DOCUMENT_NOT_FOUND), reply.getError(0).getCode());

EXPECT_EQ(uint64_t(1), f.comm_mgr->metrics().bucketSpaceMappingFailures.getValue());
}
Expand All @@ -361,7 +361,7 @@ TEST_F(CommunicationManagerTest, unmapped_bucket_space_for_get_documentapi_reque
ASSERT_EQ(1, f.reply_handler.replies.size());
auto& reply = *f.reply_handler.replies[0];
ASSERT_TRUE(reply.hasErrors());
EXPECT_EQ(static_cast<uint32_t>(api::ReturnCode::REJECTED), reply.getError(0).getCode());
EXPECT_EQ(static_cast<uint32_t>(documentapi::DocumentProtocol::ERROR_DOCUMENT_NOT_FOUND), reply.getError(0).getCode());
EXPECT_EQ(uint64_t(1), f.comm_mgr->metrics().bucketSpaceMappingFailures.getValue());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void CommunicationManager::fail_with_unresolvable_bucket_space(
MBUS_TRACE(msg->getTrace(), 6, "Communication manager: Failing message as its document type has no known bucket space mapping");
std::unique_ptr<mbus::Reply> reply;
reply = std::make_unique<mbus::EmptyReply>();
reply->addError(mbus::Error(documentapi::DocumentProtocol::ERROR_REJECTED, error_message));
reply->addError(mbus::Error(documentapi::DocumentProtocol::ERROR_DOCUMENT_NOT_FOUND, error_message));
msg->swapState(*reply);
_metrics.bucketSpaceMappingFailures.inc();
_messageBusSession->reply(std::move(reply));
Expand Down