Skip to content

Conversation

@denisgarci
Copy link
Contributor

This is not yet working, not sure how to handle the changes to ZPipeline.utfDecode in JsonCodec.scala. The changes were made in this PR zio/zio#6627.
I think I have to use a ZSink.mkString to convert the bytes into a Scala string but that would consume the stream. Is that the right approach?

@denisgarci denisgarci requested a review from a team as a code owner May 4, 2022 02:29
@CLAassistant
Copy link

CLAassistant commented May 4, 2022

CLA assistant check
All committers have signed the CLA.

@adamgfraser
Copy link
Contributor

The change is to the error type so you are going to need to transform the decoding error into a string so that it can be unified with the error type of the codec.

val zioVersion = "2.0.0-RC6"
val zioJsonVersion = "0.3.0-RC8"
val zioPreludeVersion = "1.0.0-RC14"
val zioOpticsVersion = "0.2.0-RC4"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As an aside, the previous release version for zio-optics probably got messed up, it was 2.0.0-RC4.

@denisgarci
Copy link
Contributor Author

@adamgfraser Thank you will try that.


override def decoder[A](schema: Schema[A]): ZPipeline[Any, String, Byte, A] =
ZPipeline.utfDecode >>> ZPipeline.mapZIO(
ZPipeline.fromChannel(ZPipeline.utfDecode.channel.mapError(_.toString)) >>> ZPipeline.mapZIO(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adamgfraser I tried that, but it doesn't seem to work. I get Unexpected end of input in the JsonCodecSpec tests. Any suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

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

utfDecode tries to determine the encoding by reading a BOM from the beginning of the stream, and defaults to UTF-8 if it could not find any.

I will check if there is something wrong with this logic but here you should be able to just use utf8Decode as JSON should always be in UTF-8.

Copy link
Contributor

Choose a reason for hiding this comment

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

..but that does not solve the issue, so I'm looking into it more

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you ran into this issue: #182 because the new utfDecode rechunks the stream

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vigoo Thanks for your suggestions and thanks for adding ZPipeline.mapError. I still have the same error (Unexpected end of input) using utf8Decode. Will check #182

@bilal-fazlani
Copy link

👀

@denisgarci denisgarci requested a review from vigoo May 13, 2022 21:23
@denisgarci denisgarci closed this May 23, 2022
@vigoo vigoo reopened this May 25, 2022
@vigoo
Copy link
Contributor

vigoo commented May 25, 2022

Let's release this for now until #182 gets solved to unblock dependencies, as that will be a bigger change in both json and protobuf decoders.

@vigoo vigoo merged commit d92d5f7 into zio:zio2 May 25, 2022
@denisgarci denisgarci deleted the update-zio branch May 25, 2022 18:20
jdegoes added a commit that referenced this pull request Aug 19, 2022
* Support ZIO 2.x (#149)

* Run scalafix ZIO 2 migration

* Get core project compiling

* Get Optics to compile and pass tests

* Get protobuf to compile and pass tests

* Run `sbt prepare`

* Remove unused reference to zio-nio in BuildHelper.scala

* Update to ZIO 2.0.0-RC1

* Update zio-schema-json and examples to ZIO 2

* Update dependency ch.epfl.scala:sbt-scalafix to v0.9.33 (#98)

Co-authored-by: Renovate Bot <[email protected]>

* Capture annotations on Enums and all cases (#167)

* Capture annotations on Enums and all cases

* Linting

* Update dependency com.github.ghik:silencer-lib to v1.7.7 (#123)

Co-authored-by: Renovate Bot <[email protected]>

* Upgrade zio-json to 0.3.0-RC1-1

* Update zio-prelude and zio-optics versions to ZIO-2 releases and address Adam's PR feedback

* Last bit of PR cleanup

* Fix linter error

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Dan Harris <[email protected]>

* Update ZIO2 branch to latest main (#216)

* Update dependency ch.epfl.scala:sbt-scalafix to v0.9.33 (#98)

Co-authored-by: Renovate Bot <[email protected]>

* Capture annotations on Enums and all cases (#167)

* Capture annotations on Enums and all cases

* Linting

* Update dependency com.github.ghik:silencer-lib to v1.7.7 (#123)

Co-authored-by: Renovate Bot <[email protected]>

* Update dependency org.scalameta:sbt-scalafmt to v2.4.5 (#154)

Co-authored-by: Renovate Bot <[email protected]>

* Add schema for DynamicValue (#170)

* Add Schema for DynamicValue

* Rename some of StandardType values

* Fix type casting

* Fix linting issues

Run `prepare` on the whole project

* Support native schema for Set #139 (#173)

* Support native schema for Set

* added Diff support for SetSchema

* removed dead code

* attempt to fix scala 2.13 match may not be exhaustive compile error

* added SetSchema support

* updated docs to mention zio-dynamoDB as a client

* More property based tests for map and set (#178)

* added more property based tests for Map

* added more property based tests for Set

* Diff refactor (#176)

* Diff refactor

Refactor diff. There are two main goals:

1. Add type parameter to `Dff`. This solves an otherwise very nasty issue in the Scala 3 support.

2. Use Least Common Subsequence (LCS aka Myers Diff) for all sequence diffs. This simplifies things a lot of unifies all collection diffs under a single, principled algorithm.

* Linter fixes

* Fix 2.12 build issue

* Move LCSDiff to Differ companion object

* Make LCSDiff package private

* Linting

Co-authored-by: John A. De Goes <[email protected]>

* Update dependency org.scala-native:sbt-scala-native to v0.4.3 (#180)

Co-authored-by: Renovate Bot <[email protected]>

* Update dependency org.scalameta:sbt-mdoc to v2.3.0 (#181)

Co-authored-by: Renovate Bot <[email protected]>

* Thrift (#163)

* thrift

* all tests passing

* uncommented benchmarks

* sets

* removed not implemented methods

* map

* fixes

* formatting

* small fixes

* fixes

* fixes

* failure decoding

* path as first param

* Fix compile errors for Scala 2.12

* code review

* thrift optionals

* scalafmt + compilation warnings

* removed JavaConverters

* removed JavaConverters

* scalafmt

* scalafix

* scalafix test

Co-authored-by: Dan Harris <[email protected]>
Co-authored-by: Dan Harris <[email protected]>

* Fix bug in enum schema derivation (#191)

* Unify schema of Either/Left/Right (#204)

* Update dependency org.xerial.sbt:sbt-sonatype to v3.9.12 (#186)

Co-authored-by: Renovate Bot <[email protected]>

* Update dependency org.scala-js:sbt-scalajs to v1.9.0 (#190)

Co-authored-by: Renovate Bot <[email protected]>

* Update dependency com.eed3si9n:sbt-buildinfo to v0.11.0 (#199)

Co-authored-by: Renovate Bot <[email protected]>

* Equality implementation for Schema (#206)

* Equality implementation for Schema

* Import order fix

* Improve equality of Sequence

* Fix equality, recursion, migration

* Fix warning

* Run fix

* Manually fix scalafix result

* preserve annotations when calling toRecord on a Tuple: fixes #212 (#213)

* preserve annotations when calling toRecord on a Tuple: fixes #212

* apply scalafixAll

* Format

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Dan Harris <[email protected]>
Co-authored-by: Ivan Grebenik <[email protected]>
Co-authored-by: Avinder Bahra <[email protected]>
Co-authored-by: Avinder Bahra <[email protected]>
Co-authored-by: John A. De Goes <[email protected]>
Co-authored-by: František Kocun <[email protected]>
Co-authored-by: Dan Harris <[email protected]>
Co-authored-by: Tobias Pfeifer <[email protected]>

* ZIO2 latest update from main (#222)

* Update dependency ch.epfl.scala:sbt-scalafix to v0.9.33 (#98)

Co-authored-by: Renovate Bot <[email protected]>

* Capture annotations on Enums and all cases (#167)

* Capture annotations on Enums and all cases

* Linting

* Update dependency com.github.ghik:silencer-lib to v1.7.7 (#123)

Co-authored-by: Renovate Bot <[email protected]>

* Update dependency org.scalameta:sbt-scalafmt to v2.4.5 (#154)

Co-authored-by: Renovate Bot <[email protected]>

* Add schema for DynamicValue (#170)

* Add Schema for DynamicValue

* Rename some of StandardType values

* Fix type casting

* Fix linting issues

Run `prepare` on the whole project

* Support native schema for Set #139 (#173)

* Support native schema for Set

* added Diff support for SetSchema

* removed dead code

* attempt to fix scala 2.13 match may not be exhaustive compile error

* added SetSchema support

* updated docs to mention zio-dynamoDB as a client

* More property based tests for map and set (#178)

* added more property based tests for Map

* added more property based tests for Set

* Diff refactor (#176)

* Diff refactor

Refactor diff. There are two main goals:

1. Add type parameter to `Dff`. This solves an otherwise very nasty issue in the Scala 3 support.

2. Use Least Common Subsequence (LCS aka Myers Diff) for all sequence diffs. This simplifies things a lot of unifies all collection diffs under a single, principled algorithm.

* Linter fixes

* Fix 2.12 build issue

* Move LCSDiff to Differ companion object

* Make LCSDiff package private

* Linting

Co-authored-by: John A. De Goes <[email protected]>

* Update dependency org.scala-native:sbt-scala-native to v0.4.3 (#180)

Co-authored-by: Renovate Bot <[email protected]>

* Update dependency org.scalameta:sbt-mdoc to v2.3.0 (#181)

Co-authored-by: Renovate Bot <[email protected]>

* Thrift (#163)

* thrift

* all tests passing

* uncommented benchmarks

* sets

* removed not implemented methods

* map

* fixes

* formatting

* small fixes

* fixes

* fixes

* failure decoding

* path as first param

* Fix compile errors for Scala 2.12

* code review

* thrift optionals

* scalafmt + compilation warnings

* removed JavaConverters

* removed JavaConverters

* scalafmt

* scalafix

* scalafix test

Co-authored-by: Dan Harris <[email protected]>
Co-authored-by: Dan Harris <[email protected]>

* Fix bug in enum schema derivation (#191)

* Unify schema of Either/Left/Right (#204)

* Update dependency org.xerial.sbt:sbt-sonatype to v3.9.12 (#186)

Co-authored-by: Renovate Bot <[email protected]>

* Update dependency org.scala-js:sbt-scalajs to v1.9.0 (#190)

Co-authored-by: Renovate Bot <[email protected]>

* Update dependency com.eed3si9n:sbt-buildinfo to v0.11.0 (#199)

Co-authored-by: Renovate Bot <[email protected]>

* Equality implementation for Schema (#206)

* Equality implementation for Schema

* Import order fix

* Improve equality of Sequence

* Fix equality, recursion, migration

* Fix warning

* Run fix

* Manually fix scalafix result

* preserve annotations when calling toRecord on a Tuple: fixes #212 (#213)

* preserve annotations when calling toRecord on a Tuple: fixes #212

* apply scalafixAll

* Add special encoding for List and Map types in SchemaAst (#220)

* Add special encoding for List and Map types in SchemaAst

* revert build config chnage

* preserve optional flag

* Fix

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Dan Harris <[email protected]>
Co-authored-by: Ivan Grebenik <[email protected]>
Co-authored-by: Avinder Bahra <[email protected]>
Co-authored-by: Avinder Bahra <[email protected]>
Co-authored-by: John A. De Goes <[email protected]>
Co-authored-by: František Kocun <[email protected]>
Co-authored-by: Dan Harris <[email protected]>
Co-authored-by: Tobias Pfeifer <[email protected]>

* Dynamic and SemiDynamic schemas ZIO 2 version (#219)

* Update dependency ch.epfl.scala:sbt-scalafix to v0.9.33 (#98)

Co-authored-by: Renovate Bot <[email protected]>

* Capture annotations on Enums and all cases (#167)

* Capture annotations on Enums and all cases

* Linting

* Update dependency com.github.ghik:silencer-lib to v1.7.7 (#123)

Co-authored-by: Renovate Bot <[email protected]>

* Update dependency org.scalameta:sbt-scalafmt to v2.4.5 (#154)

Co-authored-by: Renovate Bot <[email protected]>

* Add schema for DynamicValue (#170)

* Add Schema for DynamicValue

* Rename some of StandardType values

* Fix type casting

* Fix linting issues

Run `prepare` on the whole project

* Support native schema for Set #139 (#173)

* Support native schema for Set

* added Diff support for SetSchema

* removed dead code

* attempt to fix scala 2.13 match may not be exhaustive compile error

* added SetSchema support

* updated docs to mention zio-dynamoDB as a client

* More property based tests for map and set (#178)

* added more property based tests for Map

* added more property based tests for Set

* Diff refactor (#176)

* Diff refactor

Refactor diff. There are two main goals:

1. Add type parameter to `Dff`. This solves an otherwise very nasty issue in the Scala 3 support.

2. Use Least Common Subsequence (LCS aka Myers Diff) for all sequence diffs. This simplifies things a lot of unifies all collection diffs under a single, principled algorithm.

* Linter fixes

* Fix 2.12 build issue

* Move LCSDiff to Differ companion object

* Make LCSDiff package private

* Linting

Co-authored-by: John A. De Goes <[email protected]>

* Update dependency org.scala-native:sbt-scala-native to v0.4.3 (#180)

Co-authored-by: Renovate Bot <[email protected]>

* Update dependency org.scalameta:sbt-mdoc to v2.3.0 (#181)

Co-authored-by: Renovate Bot <[email protected]>

* Thrift (#163)

* thrift

* all tests passing

* uncommented benchmarks

* sets

* removed not implemented methods

* map

* fixes

* formatting

* small fixes

* fixes

* fixes

* failure decoding

* path as first param

* Fix compile errors for Scala 2.12

* code review

* thrift optionals

* scalafmt + compilation warnings

* removed JavaConverters

* removed JavaConverters

* scalafmt

* scalafix

* scalafix test

Co-authored-by: Dan Harris <[email protected]>
Co-authored-by: Dan Harris <[email protected]>

* Fix bug in enum schema derivation (#191)

* Dynamic and SemiDynamic schemas

* Unify schema of Either/Left/Right (#204)

* DeriveGen

* JsonCodec

* Fix semiDynamicEncoder

* Fixes

* Update dependency org.xerial.sbt:sbt-sonatype to v3.9.12 (#186)

Co-authored-by: Renovate Bot <[email protected]>

* Update dependency org.scala-js:sbt-scalajs to v1.9.0 (#190)

Co-authored-by: Renovate Bot <[email protected]>

* Update dependency com.eed3si9n:sbt-buildinfo to v0.11.0 (#199)

Co-authored-by: Renovate Bot <[email protected]>

* Equality implementation for Schema (#206)

* Equality implementation for Schema

* Import order fix

* Improve equality of Sequence

* Fix equality, recursion, migration

* Fix warning

* Run fix

* Manually fix scalafix result

* Json codec works

* BigInt, BigDecimal support for protobuf

* Fix protobuf semi dynamic record test

* Various thrift codec fixes

* SemiDynamic support for thrift

* Fix some warnings

* Fix more warnings

* Fix compilation on 2.12

* scalafix

* format

* preserve annotations when calling toRecord on a Tuple: fixes #212 (#213)

* preserve annotations when calling toRecord on a Tuple: fixes #212

* apply scalafixAll

* Reproducer for schema ast materialization problem

* Format

* Finish todo items

* Fix bug in AST (#223)

* Fix bug in AST

* Remove unused import

* Unused import

* deprecate testM abd checM

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Dan Harris <[email protected]>
Co-authored-by: Ivan Grebenik <[email protected]>
Co-authored-by: Avinder Bahra <[email protected]>
Co-authored-by: Avinder Bahra <[email protected]>
Co-authored-by: John A. De Goes <[email protected]>
Co-authored-by: František Kocun <[email protected]>
Co-authored-by: Dan Harris <[email protected]>
Co-authored-by: Tobias Pfeifer <[email protected]>

* Remove DynamicValue.Transform (#227)

* Support for ZIO2-RC3 (#230)

* Upgrade to ZIO2 RC2

* Update to ZIO2 RC3

* Upgrade zio-json snapshot version for ZIO2-RC3

* Fix string encoding compilation error

* Try to get timeouts sorted

* Upgrade To ZIO 2.0.0-RC4 (#234)

* upgrade zio version

* remove unused import

* ZIO 2.0.0-RC5 (#238)

* Upgrade to ZIO 2.0.0-RC6 (#245)

* Upgrade to ZIO 2.0.0-RC6

* Convert error to string

* Fix schema derivation test

* Migrate test

* Switch to ZPipeline.utf8Decode

* Fix JSON decode

* fix and format

Co-authored-by: Daniel Vigovszky <[email protected]>

* Fix protobuf semidynamic encoding/decoding (#266)

* Remove Left/Right/None/Nil implicit schemas (#279)

* Fix for DynamicValue.Record field order mixed up by serialization  (#284)

* Reproducer for Dynamic Record field order issue

* Fix

* Update to ZIO 2.0.0 final (#290)

* feature: add `toTypedPrimitive` operator to `StandardType` (#300)

* feature: add `toTypedPrimitive` operator to StandardType

* chore: update style

* Fix

* Fixes

* Settings fix

* Fix build helper

* Scala 3 fixes

* Thrift codec Scala3 fixes

* Scala3 fix

* More Scala3 fix

* Copied memory settings from zio/zio

* Trying other memory settings

* More fixes

* Force rebuild

* Make AvroCodec Scala 2.12 compatible

* ScalaFix

* ZIO 2.0.1

* Disable parallel execution on CI

* Do not fork tests

Co-authored-by: Alexander van Olst <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Dan Harris <[email protected]>
Co-authored-by: Ivan Grebenik <[email protected]>
Co-authored-by: Avinder Bahra <[email protected]>
Co-authored-by: Avinder Bahra <[email protected]>
Co-authored-by: John A. De Goes <[email protected]>
Co-authored-by: František Kocun <[email protected]>
Co-authored-by: Dan Harris <[email protected]>
Co-authored-by: Tobias Pfeifer <[email protected]>
Co-authored-by: Adam Fraser <[email protected]>
Co-authored-by: Denis <[email protected]>
Co-authored-by: Albert Pető <[email protected]>
Co-authored-by: Tushar Mathur <[email protected]>
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.

5 participants