|
|
@@ -3524,3 +3524,36 @@ TEST_F(ApiFixture, ADocumentInsertedWithAPlainVectorFieldMustBeFINDABLE) {
|
|
|
EXPECT_FALSE(found.count("bare")) << j.dump();
|
|
|
EXPECT_EQ(found.size(), 1u) << j.dump();
|
|
|
}
|
|
|
+
|
|
|
+TEST_F(ApiFixture, TheExportsBase64FieldGetsAnErrorThatDoesNotREADAsDataLoss) {
|
|
|
+ // The 3am restore case, raised by a consumer who had just restored a
|
|
|
+ // 294 MB export. `vector_b64` is what the exporter writes; feeding it back
|
|
|
+ // used to answer "a document must carry '_vector'", which reads as "my
|
|
|
+ // backup has no vectors" - indistinguishable from real data loss, and it
|
|
|
+ // will be believed. The message must say the backup is FINE and what to do.
|
|
|
+ auto c = admin();
|
|
|
+ const std::string base = "/api/v1/projects/" + project_ + "/collections";
|
|
|
+ ASSERT_EQ(c.Post(base.c_str(),
|
|
|
+ nlohmann::json{{"name","vb64"},{"kind","vector"},
|
|
|
+ {"vector_dimension",4}}.dump(),
|
|
|
+ "application/json")->status, 201);
|
|
|
+ auto r = c.Post((base + "/vb64/documents").c_str(),
|
|
|
+ nlohmann::json{{"vector_b64","AACAPwAAAAAAAAAAAAAAAA=="},
|
|
|
+ {"tag","from-export"}}.dump(), "application/json");
|
|
|
+ ASSERT_TRUE(r);
|
|
|
+ EXPECT_EQ(r->status, 422) << r->body;
|
|
|
+ // It must name the export's own field, so the reader knows we SAW it.
|
|
|
+ EXPECT_NE(r->body.find("vector_b64"), std::string::npos) << r->body;
|
|
|
+ // It must say the backup is fine - this is the whole point.
|
|
|
+ EXPECT_NE(r->body.find("BACKUP IS FINE"), std::string::npos) << r->body;
|
|
|
+ // And it must say what to do instead.
|
|
|
+ EXPECT_NE(r->body.find("_vector"), std::string::npos) << r->body;
|
|
|
+ // The plain `_vector` case must keep its own, different message, or this
|
|
|
+ // branch has swallowed the ordinary one.
|
|
|
+ auto plain = c.Post((base + "/vb64/documents").c_str(),
|
|
|
+ nlohmann::json{{"tag","no-vector-at-all"}}.dump(), "application/json");
|
|
|
+ ASSERT_TRUE(plain);
|
|
|
+ EXPECT_EQ(plain->status, 422) << plain->body;
|
|
|
+ EXPECT_EQ(plain->body.find("BACKUP IS FINE"), std::string::npos)
|
|
|
+ << "the ordinary missing-vector case must not claim a backup is involved: " << plain->body;
|
|
|
+}
|