Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: [null & default] Restful setting json default to none when nullable is false should prompt an error #37922

Closed
1 task done
qixuan0212 opened this issue Nov 22, 2024 · 2 comments
Assignees
Labels
kind/bug Issues or changes related a bug triage/accepted Indicates an issue or PR is ready to be actively worked on.
Milestone

Comments

@qixuan0212
Copy link
Contributor

qixuan0212 commented Nov 22, 2024

Is there an existing issue for this?

  • I have searched the existing issues

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

If nullable is false and default is set to none, no error message is displayed

Expected Behavior

Restful setting default to none when nullable is false should prompt an error.
Report errors like pymilvus:
json_field = FieldSchema(name="json", dtype=DataType.JSON, nullable=False, default_value=None) File "/Users/zilliz/Library/Python/3.9/lib/python/site-packages/pymilvus/orm/schema.py", line 408, in __init__ raise ParamError(message=ExceptionsMessage.DefaultValueInvalid) pymilvus.exceptions.ParamError: <ParamError: (code=1, message=Default value cannot be None for a field that is defined as nullable == false.)>

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": {}, "nullable": False, "defaultValue": None},
                    {"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%22wIT%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-ykmim.%2A%5C%22%7D%22,%22datasource%22:%7B%22type%22:%22loki%22,%22uid%22:%22vhI6Vw67k%22%7D%7D%5D,%22range%22:%7B%22from%22:%221732245080146%22,%22to%22:%221732245103306%22%7D%7D%7D&schemaVersion=1

Anything else?

N/A

@qixuan0212 qixuan0212 added kind/bug Issues or changes related a bug needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 22, 2024
@qixuan0212 qixuan0212 changed the title [Bug]: [null & default] Restful setting default to none when nullable is false should prompt an error [Bug]: [null & default] Restful setting json default to none when nullable is false should prompt an error Nov 22, 2024
@qixuan0212 qixuan0212 added this to the 2.5.0 milestone Nov 22, 2024
@smellthemoon
Copy link
Contributor

It is difficult to distinguish between set None and not set here, so no error is reported when the default value is set to none alone. However, if you want to insert none when nullable==false and want the default value to take effect, an error will still be reported. It means that set defaultValue = None is take no effect in restful, which will note in doc.

@smellthemoon
Copy link
Contributor

/assign @qixuan0212

@yanliang567 yanliang567 added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 22, 2024
@yanliang567 yanliang567 removed their assignment Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Issues or changes related a bug triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests

3 participants