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
Schema validation does not allow for null values in case of Optional
typed params
#2589
Comments
Extended stacktrace:
|
Maybe extending the param types with an anyOf like in https://stackoverflow.com/questions/22565005/json-schema-validate-a-number-or-null-value could help. |
Note: the suggestion above is valid, so in order to make optional parameter accept a "anyOf": [
{"type": "string"},
{"type": "null"}
] However, the node's parameter's schema is currently build entirely by Pydantic: haystack/haystack/nodes/_json_schema.py Line 179 in 0e83535
So at a first glance it seems like we can't easily change the output by just staying within Haystack's code. Next steps:
|
I tried to investigate this problem, but it's not easy 😄.
version: ignore
components:
- name: MyReader
type: FARMReader
params:
model_name_or_path: deepset/tinyroberta-squad2
model_version: null
pipelines:
- name: example_pipeline
nodes:
- name: MyReader
inputs: [Query]
|
Hey @anakin87! Thanks for jumping it! 😊 About point 1 you're right: About point 2: Wow the issue you link is really deep. I did not expect this to be so rooted into Pydantic... I think we could live with the monkeypatch while waiting for v2 to be out. The JSON schema generation in Haystack is not pretty anyway 😄 So I'd propose the following course of action, if you're up for it:
If you get stuck do not insist too much though. For as weird as it is, this issue is not mission critical. If we have to wait for Pydantic v2, so be it. Have fun! |
Describe the bug
Setting optional params to
null
in YAML (or toNone
when it's been converted to a python dict) will cause the schema validation to fail: see #2586Error message
Expected behavior
null
values are accepted forOptional
typed params.To Reproduce
Load following pipeline:
The text was updated successfully, but these errors were encountered: