mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-25 07:37:19 -04:00
Return appropriate error on null dims update instead of npe (#125716)
Calling `Object::toString` was trying to call `null.toString()`, really it should have been `Objects::toString`, which accepts `null`. closes: https://github.com/elastic/elasticsearch/issues/125713
This commit is contained in:
parent
83c0ca14f7
commit
dd58b0b6fa
6 changed files with 59 additions and 2 deletions
5
docs/changelog/125716.yaml
Normal file
5
docs/changelog/125716.yaml
Normal file
|
@ -0,0 +1,5 @@
|
|||
pr: 125716
|
||||
summary: Return appropriate error on null dims update instead of npe
|
||||
area: Vector Search
|
||||
type: bug
|
||||
issues: []
|
|
@ -605,3 +605,28 @@ setup:
|
|||
- match: { hits.hits.0._score: $knn_score0 }
|
||||
- match: { hits.hits.1._score: $knn_score1 }
|
||||
- match: { hits.hits.2._score: $knn_score2 }
|
||||
---
|
||||
"Updating dim to null is not allowed":
|
||||
- requires:
|
||||
cluster_features: "mapper.npe_on_dims_update_fix"
|
||||
reason: "dims update fix"
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_index
|
||||
|
||||
- do:
|
||||
indices.put_mapping:
|
||||
index: test_index
|
||||
body:
|
||||
properties:
|
||||
embedding:
|
||||
type: dense_vector
|
||||
dims: 4
|
||||
- do:
|
||||
catch: bad_request
|
||||
indices.put_mapping:
|
||||
index: test_index
|
||||
body:
|
||||
properties:
|
||||
embedding:
|
||||
type: dense_vector
|
||||
|
|
|
@ -39,6 +39,7 @@ public class MapperFeatures implements FeatureSpecification {
|
|||
static final NodeFeature UKNOWN_FIELD_MAPPING_UPDATE_ERROR_MESSAGE = new NodeFeature(
|
||||
"mapper.unknown_field_mapping_update_error_message"
|
||||
);
|
||||
static final NodeFeature NPE_ON_DIMS_UPDATE_FIX = new NodeFeature("mapper.npe_on_dims_update_fix");
|
||||
|
||||
@Override
|
||||
public Set<NodeFeature> getTestFeatures() {
|
||||
|
@ -64,6 +65,7 @@ public class MapperFeatures implements FeatureSpecification {
|
|||
DOC_VALUES_SKIPPER,
|
||||
RESCORE_VECTOR_QUANTIZED_VECTOR_MAPPING,
|
||||
DateFieldMapper.INVALID_DATE_FIX,
|
||||
NPE_ON_DIMS_UPDATE_FIX,
|
||||
RESCORE_ZERO_VECTOR_QUANTIZED_VECTOR_MAPPING
|
||||
);
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ public class DenseVectorFieldMapper extends FieldMapper {
|
|||
}
|
||||
|
||||
return XContentMapValues.nodeIntegerValue(o);
|
||||
}, m -> toType(m).fieldType().dims, XContentBuilder::field, Object::toString).setSerializerCheck((id, ic, v) -> v != null)
|
||||
}, m -> toType(m).fieldType().dims, XContentBuilder::field, Objects::toString).setSerializerCheck((id, ic, v) -> v != null)
|
||||
.setMergeValidator((previous, current, c) -> previous == null || Objects.equals(previous, current))
|
||||
.addValidator(dims -> {
|
||||
if (dims == null) {
|
||||
|
|
|
@ -89,7 +89,7 @@ public class RankVectorsFieldMapper extends FieldMapper {
|
|||
}
|
||||
|
||||
return XContentMapValues.nodeIntegerValue(o);
|
||||
}, m -> toType(m).fieldType().dims, XContentBuilder::field, Object::toString).setSerializerCheck((id, ic, v) -> v != null)
|
||||
}, m -> toType(m).fieldType().dims, XContentBuilder::field, Objects::toString).setSerializerCheck((id, ic, v) -> v != null)
|
||||
.setMergeValidator((previous, current, c) -> previous == null || Objects.equals(previous, current))
|
||||
.addValidator(dims -> {
|
||||
if (dims == null) {
|
||||
|
|
|
@ -135,3 +135,28 @@ setup:
|
|||
id: "1"
|
||||
body:
|
||||
vector1: [[2, -1, 1], [[2, -1, 1]]]
|
||||
---
|
||||
"Updating dim to null is not allowed":
|
||||
- requires:
|
||||
cluster_features: "mapper.npe_on_dims_update_fix"
|
||||
reason: "dims update fix"
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_index
|
||||
|
||||
- do:
|
||||
indices.put_mapping:
|
||||
index: test_index
|
||||
body:
|
||||
properties:
|
||||
embedding:
|
||||
type: rank_vectors
|
||||
dims: 4
|
||||
- do:
|
||||
catch: bad_request
|
||||
indices.put_mapping:
|
||||
index: test_index
|
||||
body:
|
||||
properties:
|
||||
embedding:
|
||||
type: rank_vectors
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue