diff --git a/src/middlewared/middlewared/api/base/types/base/string.py b/src/middlewared/middlewared/api/base/types/base/string.py index c0204d50ea2a4..827d263e6c984 100644 --- a/src/middlewared/middlewared/api/base/types/base/string.py +++ b/src/middlewared/middlewared/api/base/types/base/string.py @@ -51,7 +51,7 @@ def __get_pydantic_core_schema__( LongString = Annotated[ LongStringWrapper, BeforeValidator(LongStringWrapper), - PlainSerializer(lambda x: undefined if x == undefined else x.value), + PlainSerializer(lambda x: x.value if isinstance(x, LongStringWrapper) else x), ] NonEmptyString = Annotated[str, Field(min_length=1)] diff --git a/src/middlewared/middlewared/api/v25_04_0/cloud_backup.py b/src/middlewared/middlewared/api/v25_04_0/cloud_backup.py index a5f80b22662f9..d67155c15db40 100644 --- a/src/middlewared/middlewared/api/v25_04_0/cloud_backup.py +++ b/src/middlewared/middlewared/api/v25_04_0/cloud_backup.py @@ -31,8 +31,8 @@ class CloudBackupCreate(BaseModel): pre_script: LongString = "" post_script: LongString = "" snapshot: bool = False - include: list[NonEmptyString] - exclude: list[NonEmptyString] + include: list[NonEmptyString] = [] + exclude: list[NonEmptyString] = [] args: LongString = "" enabled: bool = True diff --git a/src/middlewared/middlewared/pytest/unit/api/base/types/test_base.py b/src/middlewared/middlewared/pytest/unit/api/base/types/test_base.py index 966e80d3e1f85..7d917ac56e5a5 100644 --- a/src/middlewared/middlewared/pytest/unit/api/base/types/test_base.py +++ b/src/middlewared/middlewared/pytest/unit/api/base/types/test_base.py @@ -40,3 +40,11 @@ class SecretLongStringMethodArgs(BaseModel): def test_secret_long_string(): assert accept_params(SecretLongStringMethodArgs, ["test"]) == ["test"] + + +class LongStringDefaultMethodArgs(BaseModel): + str: LongString = "" + + +def test_long_string_default(): + assert accept_params(LongStringDefaultMethodArgs, []) == [""] diff --git a/tests/api2/test_account_privilege_role_private_fields.py b/tests/api2/test_account_privilege_role_private_fields.py index 91df0f1f3b477..40db7537c0475 100644 --- a/tests/api2/test_account_privilege_role_private_fields.py +++ b/tests/api2/test_account_privilege_role_private_fields.py @@ -168,7 +168,7 @@ def vmware(): ("acme.dns.authenticator", dns_authenticator, {}, ["attributes"]), ("certificate", 1, {}, ["privatekey", "issuer"]), ("certificateauthority", certificateauthority, {}, ["privatekey", "issuer"]), - ("cloud_backup", cloudbackup, {}, ["credentials.provider", "password"]), + ("cloud_backup", cloudbackup, {}, ["credentials.provider.pass", "password"]), ("cloudsync.credentials", cloudsync_credential, {}, ["provider.pass"]), ("cloudsync", cloudsync, {}, ["credentials.provider", "encryption_password"]), ("disk", disk, {"extra": {"passwords": True}}, ["passwd"]),