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

Reproducer for #3144 #3214

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Reproducer for #3144 #3214

wants to merge 2 commits into from

Conversation

guizmaii
Copy link
Member

@guizmaii guizmaii commented Nov 19, 2024

See #3144

The issue seems to be that for a Schema[Option[A]] we need to create a HttpContentCondec.fromSchema(Schema[A]).optional

for {
response <- api.runZIO(makeRequest(body))
body <- response.body.asString
} yield assertTrue(body == """{"no":"body"}""")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fails with:

  - OptionalBodySpec / accepts empty body - 78 ms
     "{\"name\":\"MalformedBody\",\"message\":\"Malformed request body failed to decode: Unexpected end of input\"}" was not equal to "{\"no\":\"body\"}"
    body == """{"no":"body"}"""
    body = "{\"name\":\"MalformedBody\",\"message\":\"Malformed request body failed to decode: Unexpected end of input\"}"
    at /Users/jules/jules_ivanic/workspace/zio-http/zio-http/jvm/src/test/scala/zio/http/endpoint/OptionalBodySpec.scala:57 

@guizmaii guizmaii marked this pull request as draft November 19, 2024 05:42
Comment on lines +425 to +428
val isOptional = EnvironmentTag[Input2] <:< EnvironmentTag[Option[?]]
println(s"==================== Is optional: $isOptional ==================== ")
copy(input = input ++ (if (isOptional) codec.optional.asInstanceOf[zio.http.codec.HttpCodec[zio.http.codec.HttpCodecType.RequestType,Input2]] else codec))
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I attempted a fix here but the result is that it makes fail the only test which was passing and the test which was failing still fails

@guizmaii guizmaii self-assigned this Dec 16, 2024
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 this pull request may close these issues.

1 participant