TapirStubInterpreter - class zio.stream.ZStream cannot be cast to scala.util.Either

When testing tapir endpoint with ZioStreams capability using TapirStubInterpreter(SttpBackendStub(zioMonad)) I’m geting ClassCastException on response decoding to Either:

  def asStream: ResponseAs[Either[String, Chunk[Byte]], Effect[Task] & ZioStreams] =
    client3.asStream(ZioStreams)(s => s.run(ZSink.collectAll))

I noticed that only asStreamAlwaysUnsafe(ZioStreams) is covered by tests: tapir/server/zio-http-server/src/test/scala/sttp/tapir/server/ziohttp/ZioHttpServerTest.scala at 048205772f02fd7323b9a5a5ae1e2d0f4ce5f586 · softwaremill/tapir · GitHub

asStreamWithMetadata also results in ClassCastException

Fixed here: When the stub interpreter returns a stream, instruct the stub backend to always treat it as a raw stream by adamw · Pull Request #4380 · softwaremill/tapir · GitHub