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

Incorrect behaviour of ArgBuilder containing only nullable fields when input is null #2407

Closed
kyri-petrou opened this issue Sep 17, 2024 · 2 comments · Fixed by #2408
Closed

Comments

@kyri-petrou
Copy link
Collaborator

kyri-petrou commented Sep 17, 2024

Given the following case class:

case class Foo(value1: Option[String], value2: Option[String]) derives ArgBuilder

I expect that the derived ArgBuilder#build should work in the following ways:

  1. Input: {}, output: Right(Foo(None, None))
  2. Input: null, output Left(ExecutionError("bla"))

However, currently both cases succeed with Foo(None, None). Can be reproduced with the following test that should pass but fails since the first condition is not Left

    suite("derived build")(
      test("should fail when null is provided for case class with optional fields") {
        case class Foo(value: Option[String])
        val ab = ArgBuilder.gen[Foo]
        assertTrue(
          ab.build(NullValue).isLeft,
          ab.build(ObjectValue(Map())).isRight
        )
      }
    )

PS: This is not a problem when validation is enabled as an error will be raised during the validation phase

@kyri-petrou
Copy link
Collaborator Author

@ghostdogpr are you aware of anything that relies on the ArgBuilder succeeding when null is provided instead of {}?

@ghostdogpr
Copy link
Owner

Hmm yeah that looks like a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants