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

Flow parameters silently fall back to defaults on validation error #16184

Open
j-tr opened this issue Dec 3, 2024 · 1 comment
Open

Flow parameters silently fall back to defaults on validation error #16184

j-tr opened this issue Dec 3, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@j-tr
Copy link
Contributor

j-tr commented Dec 3, 2024

Bug summary

Deploying this flow (running prefect deploy command) will result in a deployment with my_int = 5 and my_string = "bar" as default values.

from prefect import flow
from pydantic import BaseModel


class MyModel(BaseModel):
    my_int: int = 3
    my_string: str = "foo"


@flow
def test(param: MyModel = MyModel(my_int=5, my_string="bar")):
    pass

However, deploying this flow will result in a deployment with my_int = 3 and my_string = "foo" as default values.

from prefect import flow
from pydantic import BaseModel


class MyModel(BaseModel):
    my_int: int = 3
    my_string: str = "foo"


@flow
def test(param: MyModel = MyModel(my_int="foobar", my_string="bar")):
    pass

To me, this is unexpected behavior as I would expect the deployment to fail because the parameter value "foobar" doesn't match the type of my_int and should therefore fail validation.
Instead, Prefect falls back to the model default values. This is especially problematic as not only the one parameter that fails validation is reset to the model default but also all other parameters (see my_string being "foo" instead of "bar") are reset.

For more complex default value configurations, this means that one single value that doesn't conform to the schema will cause all values to be reset to defaults without the user being warned about it in any form. From a developers perspective, it should be safe to assume that a created deployment matches exactly the provided defaults if the deployment command didn't report any error.

Version info

Version:             2.20.14
API version:         0.8.4
Python version:      3.10.12
Git commit:          fb919c67
Built:               Mon, Nov 18, 2024 4:41 PM
OS/Arch:             linux/x86_64
Server type:         cloud

Additional context

No response

@j-tr j-tr added the bug Something isn't working label Dec 3, 2024
@zzstoatzz
Copy link
Collaborator

hi @j-tr - hrm yeah I agree that we should fail. can you clarify which version of pydantic you are using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants