milvus-io / milvus

A cloud-native vector database, storage for next generation AI applications
https://milvus.io
Apache License 2.0
30.87k stars 2.94k forks source link

[Bug]: [null & default] error message by restful is not clear when setting default value for json #37900

Open qixuan0212 opened 1 day ago

qixuan0212 commented 1 day ago

Is there an existing issue for this?

Environment

- Milvus version:master-20241119-484c6b5c-amd64
- Deployment mode(standalone or cluster):both
- MQ type(rocksmq, pulsar or kafka): pulsar   
- SDK version(e.g. pymilvus v2.0.0rc2): restful
- OS(Ubuntu or CentOS): 
- CPU/Memory: 
- GPU: 
- Others:

Current Behavior

when setting default value for json, error message as follows: {'code': 1100, 'message': 'convert defaultValue fail, err:Unexpected default value type: 23: invalid parameter'}

Expected Behavior

when setting default value for json, error messages should be clear and do not have vague words like "23".

Steps To Reproduce

    def test_create_collections_with_json_field_default(self):
        """
        json field not support default value
        """
        name = gen_collection_name()
        dim = 128
        client = self.collection_client
        payload = {
            "collectionName": name,
            "schema": {
                "fields": [
                    {"fieldName": "book_id", "dataType": "Int64", "isPrimary": True, "elementTypeParams": {}},
                    {"fieldName": "word_count", "dataType": "Int64", "elementTypeParams": {}},
                    {"fieldName": "book_describe", "dataType": "VarChar", "elementTypeParams": {"max_length": "256"}},
                    {"fieldName": "json", "dataType": "JSON", "elementTypeParams": {}, "defaultValue": {"key": 1}},
                    {"fieldName": "book_intro", "dataType": "FloatVector", "elementTypeParams": {"dim": f"{dim}"}}
                ]
            }
        }
        logging.info(f"create collection {name} with payload: {payload}")
        rsp = client.collection_create(payload)
        assert rsp['code'] == 1100

Milvus Log

https://grafana-4am.zilliz.cc/explore?orgId=1&panes=%7B%22jmr%22:%7B%22datasource%22:%22vhI6Vw67k%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22%7Bcluster%3D%5C%224am%5C%22,namespace%3D%5C%22qa-milvus%5C%22,pod%3D~%5C%22default-none-qx-stlif.%2A%5C%22%7D%22,%22datasource%22:%7B%22type%22:%22loki%22,%22uid%22:%22vhI6Vw67k%22%7D%7D%5D,%22range%22:%7B%22from%22:%221732181394104%22,%22to%22:%221732181493731%22%7D%7D%7D&schemaVersion=1

Anything else?

N/A

yanliang567 commented 1 day ago

/assign @smellthemoon /unassign