mirror of
https://github.com/qdrant/qdrant.git
synced 2026-08-03 00:20:57 -05:00
* actix validation * add check for memmap/indexing_threshold * fix actix json settings * Validate settings configuration on start, print pretty warnings on fail * Add more validation rules for settings and nested types * Move shared validation logic into collection/operations * Show validation warning in log when loading some internal configs * Show prettier actix JSON validation errors * Stubs for pretty handling of query errors, reformat validation errors * Use crate flatten function, the hard work was already done for us We don't have to flatten validation errors into their qualified field names ourselves because there is a utility function for this. * Configure actix path validator * Actix endpoints don't require public * Extend validation to more actix types * Validate all remaining actix path and query properties * Rephrase range validation messages to clearly describe they're inclusive * Validate all query params to respond with pretty deserialize errors * Nicely format JSON payload deserialize error responses * Improve error reporting for upsert point batches * Add basic validation test that checks a path, query and payload value * Add some validation constraints * Add simple validation error render test * Update Cargo.lock --------- Co-authored-by: timvisee <tim+github@visee.me>
73 lines
2.5 KiB
Python
73 lines
2.5 KiB
Python
import pytest
|
|
|
|
from .helpers.collection_setup import basic_collection_setup, drop_collection
|
|
from .helpers.helpers import request_with_validation
|
|
|
|
collection_name = 'test_collection'
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def setup():
|
|
basic_collection_setup(collection_name=collection_name)
|
|
yield
|
|
drop_collection(collection_name=collection_name)
|
|
|
|
|
|
def test_validation():
|
|
# Collection names are limited to 255 chars due to filesystem constraints
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}/points/{id}',
|
|
method="GET",
|
|
path_params={
|
|
'collection_name': '''\
|
|
extremelylongnameextremelylongnameextremelylongname\
|
|
extremelylongnameextremelylongnameextremelylongname\
|
|
extremelylongnameextremelylongnameextremelylongname\
|
|
extremelylongnameextremelylongnameextremelylongname\
|
|
extremelylongnameextremelylongnameextremelylongname\
|
|
extremelylongnameextremelylongnameextremelylongname\
|
|
''',
|
|
'id': 1,
|
|
},
|
|
)
|
|
assert not response.ok
|
|
assert 'Validation error' in response.json()["status"]["error"]
|
|
|
|
# Illegal body parameters must trigger a validation error
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}',
|
|
method="PUT",
|
|
path_params={'collection_name': collection_name},
|
|
body={
|
|
"vectors": {
|
|
"size": 4,
|
|
"distance": "Dot"
|
|
},
|
|
"optimizers_config": {
|
|
"memmap_threshold": 100,
|
|
"indexing_threshold": 100,
|
|
},
|
|
}
|
|
)
|
|
assert not response.ok
|
|
assert 'Validation error' in response.json()["status"]["error"]
|
|
assert 'optimizers_config.memmap_threshold' in response.json()["status"]["error"]
|
|
assert 'optimizers_config.indexing_threshold' in response.json()["status"]["error"]
|
|
|
|
# Illegal URL parameters must trigger a validation error
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}',
|
|
method="PUT",
|
|
path_params={'collection_name': collection_name},
|
|
query_params={'timeout': 0},
|
|
body={
|
|
"vectors": {
|
|
"size": 4,
|
|
"distance": "Dot"
|
|
},
|
|
}
|
|
)
|
|
assert not response.ok
|
|
assert 'Validation error' in response.json()["status"]["error"]
|
|
assert 'timeout: value 0 invalid' in response.json()["status"]["error"]
|