From cada14801bd79a62dd303303964b0fcdc918da10 Mon Sep 17 00:00:00 2001 From: Johan Solbakken Date: Fri, 14 Feb 2025 15:29:25 +0000 Subject: [PATCH 1/2] Return 404 if document type does not exist --- .../yahoo/documentapi/messagebus/MessageBusAsyncSession.java | 4 +++- .../src/vespa/storage/storageserver/communicationmanager.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/MessageBusAsyncSession.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/MessageBusAsyncSession.java index 2d1792442a09..81772b31b7e7 100644 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/MessageBusAsyncSession.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/MessageBusAsyncSession.java @@ -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; diff --git a/storage/src/vespa/storage/storageserver/communicationmanager.cpp b/storage/src/vespa/storage/storageserver/communicationmanager.cpp index 2c91aec48c5a..517c477d289d 100644 --- a/storage/src/vespa/storage/storageserver/communicationmanager.cpp +++ b/storage/src/vespa/storage/storageserver/communicationmanager.cpp @@ -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 reply; reply = std::make_unique(); - 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)); From bb55750afa472b53b63a3e1fcb07122f0f00ea5e Mon Sep 17 00:00:00 2001 From: Johan Solbakken Date: Fri, 21 Feb 2025 13:39:03 +0000 Subject: [PATCH 2/2] Update unmapped bucket space error codes in CommunicationManagerTest --- storage/src/tests/storageserver/communicationmanagertest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/src/tests/storageserver/communicationmanagertest.cpp b/storage/src/tests/storageserver/communicationmanagertest.cpp index e627fcbe4525..6ffdd5476df9 100644 --- a/storage/src/tests/storageserver/communicationmanagertest.cpp +++ b/storage/src/tests/storageserver/communicationmanagertest.cpp @@ -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(api::ReturnCode::REJECTED), reply.getError(0).getCode()); + EXPECT_EQ(static_cast(documentapi::DocumentProtocol::ERROR_DOCUMENT_NOT_FOUND), reply.getError(0).getCode()); EXPECT_EQ(uint64_t(1), f.comm_mgr->metrics().bucketSpaceMappingFailures.getValue()); } @@ -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(api::ReturnCode::REJECTED), reply.getError(0).getCode()); + EXPECT_EQ(static_cast(documentapi::DocumentProtocol::ERROR_DOCUMENT_NOT_FOUND), reply.getError(0).getCode()); EXPECT_EQ(uint64_t(1), f.comm_mgr->metrics().bucketSpaceMappingFailures.getValue()); }