Skip to content

Conversation

@andreisilviudragnea
Copy link

@andreisilviudragnea andreisilviudragnea commented Oct 20, 2022

JsonDecoder {
  final def decodeJson(str: CharSequence): Either[String, A]
  def fromJsonAST(json: Json): Either[String, A]
}
  • Derived JsonDecoders have different errors for:
    • missing fields when calling JsonDecoder.decodeJson (".b.c.v2(missing)") vs JsonDecoder.fromJsonAST ("Missing fields: v2, v3")
    • invalid types when calling JsonDecoder.decodeJson (".b.c.v1(expected '\"' got '1')") vs JsonDecoder.fromJsonAST ("Not a string value").
  • The errors reported by JsonDecoder.fromJsonAST seem to be broken because the JSON path to the error is missing from the messages: "Missing fields: v2, v3", "Not a string value".

Scala 3 derived decoders fail at runtime with StackOverflowError for now. This might be another bug.

@andreisilviudragnea andreisilviudragnea requested a review from a team as a code owner October 20, 2022 19:47
@CLAassistant
Copy link

CLAassistant commented Oct 20, 2022

CLA assistant check
All committers have signed the CLA.

@andreisilviudragnea andreisilviudragnea force-pushed the decodeJson-fromJsonAST-error-consistency branch from 15a8aa4 to 14ecac1 Compare October 24, 2022 15:10
@andreisilviudragnea
Copy link
Author

@fsvehla There seems to be a StackOverflowError problem when running the tests on Scala 3, but I am interested at the moment on the Scala 2 implementation.

Scala 3 decoder generation is different from Scala 2, so I think I might have found another bug or maybe the test is not written in the right file.

@andreisilviudragnea andreisilviudragnea changed the title Derived JsonDecoder decodeJson vs fromJsonAST error consistency Derived JsonDecoder decodeJson vs fromJsonAST error inconsistency tests Oct 24, 2022
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.

2 participants