Skip to content

Commit a861200

Browse files
committed
Merge branch 'fix_community_id_port' of github.com:mjwolf/elasticsearch into fix_community_id_port
2 parents c5a569f + 33b70f1 commit a861200

File tree

10 files changed

+89
-7
lines changed

10 files changed

+89
-7
lines changed

docs/changelog/125716.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 125716
2+
summary: Return appropriate error on null dims update instead of npe
3+
area: Vector Search
4+
type: bug
5+
issues: []

muted-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,9 @@ tests:
390390
- class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT
391391
method: test {p0=cat.allocation/10_basic/Node forecasts}
392392
issue: https://github.com/elastic/elasticsearch/issues/125711
393+
- class: org.elasticsearch.xpack.migrate.action.ReindexDataStreamTransportActionIT
394+
method: testAlreadyUpToDateDataStream
395+
issue: https://github.com/elastic/elasticsearch/issues/125727
393396

394397
# Examples:
395398
#

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.vectors/40_knn_search.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,3 +605,28 @@ setup:
605605
- match: { hits.hits.0._score: $knn_score0 }
606606
- match: { hits.hits.1._score: $knn_score1 }
607607
- match: { hits.hits.2._score: $knn_score2 }
608+
---
609+
"Updating dim to null is not allowed":
610+
- requires:
611+
cluster_features: "mapper.npe_on_dims_update_fix"
612+
reason: "dims update fix"
613+
- do:
614+
indices.create:
615+
index: test_index
616+
617+
- do:
618+
indices.put_mapping:
619+
index: test_index
620+
body:
621+
properties:
622+
embedding:
623+
type: dense_vector
624+
dims: 4
625+
- do:
626+
catch: bad_request
627+
indices.put_mapping:
628+
index: test_index
629+
body:
630+
properties:
631+
embedding:
632+
type: dense_vector

server/src/main/java/org/elasticsearch/index/mapper/MapperFeatures.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class MapperFeatures implements FeatureSpecification {
3939
static final NodeFeature UKNOWN_FIELD_MAPPING_UPDATE_ERROR_MESSAGE = new NodeFeature(
4040
"mapper.unknown_field_mapping_update_error_message"
4141
);
42+
static final NodeFeature NPE_ON_DIMS_UPDATE_FIX = new NodeFeature("mapper.npe_on_dims_update_fix");
4243

4344
@Override
4445
public Set<NodeFeature> getTestFeatures() {
@@ -64,6 +65,7 @@ public Set<NodeFeature> getTestFeatures() {
6465
DOC_VALUES_SKIPPER,
6566
RESCORE_VECTOR_QUANTIZED_VECTOR_MAPPING,
6667
DateFieldMapper.INVALID_DATE_FIX,
68+
NPE_ON_DIMS_UPDATE_FIX,
6769
RESCORE_ZERO_VECTOR_QUANTIZED_VECTOR_MAPPING
6870
);
6971
}

server/src/main/java/org/elasticsearch/index/mapper/vectors/DenseVectorFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public static class Builder extends FieldMapper.Builder {
154154
}
155155

156156
return XContentMapValues.nodeIntegerValue(o);
157-
}, m -> toType(m).fieldType().dims, XContentBuilder::field, Object::toString).setSerializerCheck((id, ic, v) -> v != null)
157+
}, m -> toType(m).fieldType().dims, XContentBuilder::field, Objects::toString).setSerializerCheck((id, ic, v) -> v != null)
158158
.setMergeValidator((previous, current, c) -> previous == null || Objects.equals(previous, current))
159159
.addValidator(dims -> {
160160
if (dims == null) {

test/fixtures/s3-fixture/src/main/java/fixture/s3/S3HttpHandler.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public void handle(final HttpExchange exchange) throws IOException {
150150
exchange.sendResponseHeaders(RestStatus.OK.getStatus(), response.length);
151151
exchange.getResponseBody().write(response);
152152

153-
} else if (Regex.simpleMatch("PUT /" + path + "/*?uploadId=*&partNumber=*", request)) {
153+
} else if (isUploadPartRequest(request)) {
154154
final Map<String, String> params = new HashMap<>();
155155
RestUtils.decodeQueryString(request, request.indexOf('?') + 1, params);
156156

@@ -213,7 +213,7 @@ public void handle(final HttpExchange exchange) throws IOException {
213213
exchange.getResponseHeaders().add("ETag", blob.v1());
214214
exchange.sendResponseHeaders(RestStatus.OK.getStatus(), -1);
215215

216-
} else if (Regex.simpleMatch("GET /" + bucket + "/?prefix=*", request)) {
216+
} else if (isListObjectsRequest(request)) {
217217
final Map<String, String> params = new HashMap<>();
218218
RestUtils.decodeQueryString(request, request.indexOf('?') + 1, params);
219219
if (params.get("list-type") != null) {
@@ -315,7 +315,7 @@ public void handle(final HttpExchange exchange) throws IOException {
315315
}
316316
exchange.sendResponseHeaders((deletions > 0 ? RestStatus.OK : RestStatus.NO_CONTENT).getStatus(), -1);
317317

318-
} else if (Regex.simpleMatch("POST /" + bucket + "/?delete", request)) {
318+
} else if (isMultiObjectDeleteRequest(request)) {
319319
final String requestBody = Streams.copyToString(new InputStreamReader(exchange.getRequestBody(), UTF_8));
320320

321321
final StringBuilder deletes = new StringBuilder();
@@ -337,16 +337,36 @@ public void handle(final HttpExchange exchange) throws IOException {
337337
exchange.getResponseBody().write(response);
338338

339339
} else {
340+
logger.error("unknown request: {}", request);
340341
exchange.sendResponseHeaders(RestStatus.INTERNAL_SERVER_ERROR.getStatus(), -1);
341342
}
343+
} catch (Exception e) {
344+
logger.error("exception in request " + request, e);
345+
throw e;
342346
} finally {
343347
exchange.close();
344348
}
345349
}
346350

351+
private boolean isUploadPartRequest(String request) {
352+
return Regex.simpleMatch("PUT /" + path + "/*?uploadId=*&partNumber=*", request)
353+
|| Regex.simpleMatch("PUT /" + path + "/*?partNumber=*&uploadId=*", request);
354+
}
355+
347356
private boolean isListMultipartUploadsRequest(String request) {
348357
return Regex.simpleMatch("GET /" + bucket + "/?uploads&prefix=*", request)
349-
|| Regex.simpleMatch("GET /" + bucket + "/?uploads&max-uploads=*&prefix=*", request);
358+
|| Regex.simpleMatch("GET /" + bucket + "/?uploads&max-uploads=*&prefix=*", request)
359+
|| Regex.simpleMatch("GET /" + bucket + "?uploads&prefix=*", request)
360+
|| Regex.simpleMatch("GET /" + bucket + "?uploads&max-uploads=*&prefix=*", request);
361+
}
362+
363+
private boolean isListObjectsRequest(String request) {
364+
return Regex.simpleMatch("GET /" + bucket + "/?prefix=*", request)
365+
|| Regex.simpleMatch("GET /" + bucket + "?list-type=2&*prefix=*", request);
366+
}
367+
368+
private boolean isMultiObjectDeleteRequest(String request) {
369+
return request.equals("POST /" + bucket + "/?delete") || request.equals("POST /" + bucket + "?delete");
350370
}
351371

352372
public Map<String, BytesReference> blobs() {

x-pack/plugin/rank-vectors/src/main/java/org/elasticsearch/xpack/rank/vectors/mapper/RankVectorsFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static class Builder extends FieldMapper.Builder {
8989
}
9090

9191
return XContentMapValues.nodeIntegerValue(o);
92-
}, m -> toType(m).fieldType().dims, XContentBuilder::field, Object::toString).setSerializerCheck((id, ic, v) -> v != null)
92+
}, m -> toType(m).fieldType().dims, XContentBuilder::field, Objects::toString).setSerializerCheck((id, ic, v) -> v != null)
9393
.setMergeValidator((previous, current, c) -> previous == null || Objects.equals(previous, current))
9494
.addValidator(dims -> {
9595
if (dims == null) {

x-pack/plugin/snapshot-repo-test-kit/qa/s3/src/javaRestTest/java/org/elasticsearch/repositories/blobstore/testkit/analyze/S3RepositoryAnalysisRestIT.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import fixture.s3.S3HttpFixture;
1010

1111
import org.elasticsearch.common.settings.Settings;
12+
import org.elasticsearch.common.unit.ByteSizeValue;
1213
import org.elasticsearch.test.cluster.ElasticsearchCluster;
1314
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
1415
import org.junit.ClassRule;
@@ -59,6 +60,7 @@ protected Settings repositorySettings() {
5960
.put("bucket", bucket)
6061
.put("base_path", basePath)
6162
.put("delete_objects_max_size", between(1, 1000))
63+
.put("buffer_size", ByteSizeValue.ofMb(5)) // so some uploads are multipart ones
6264
.build();
6365
}
6466
}

x-pack/plugin/snapshot-repo-test-kit/src/test/java/org/elasticsearch/repositories/blobstore/testkit/analyze/AbstractRepositoryAnalysisRestTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void testRepositoryAnalysis() throws Exception {
2929
final Request request = new Request(HttpPost.METHOD_NAME, "/_snapshot/" + repository + "/_analyze");
3030
request.addParameter("blob_count", "10");
3131
request.addParameter("concurrency", "4");
32-
request.addParameter("max_blob_size", "1mb");
32+
request.addParameter("max_blob_size", randomFrom("1mb", "10mb"));
3333
request.addParameter("timeout", "120s");
3434
request.addParameter("seed", Long.toString(randomLong()));
3535
assertOK(client().performRequest(request));

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/rank_vectors/rank_vectors.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,28 @@ setup:
135135
id: "1"
136136
body:
137137
vector1: [[2, -1, 1], [[2, -1, 1]]]
138+
---
139+
"Updating dim to null is not allowed":
140+
- requires:
141+
cluster_features: "mapper.npe_on_dims_update_fix"
142+
reason: "dims update fix"
143+
- do:
144+
indices.create:
145+
index: test_index
146+
147+
- do:
148+
indices.put_mapping:
149+
index: test_index
150+
body:
151+
properties:
152+
embedding:
153+
type: rank_vectors
154+
dims: 4
155+
- do:
156+
catch: bad_request
157+
indices.put_mapping:
158+
index: test_index
159+
body:
160+
properties:
161+
embedding:
162+
type: rank_vectors

0 commit comments

Comments
 (0)