Circe throws an exception when parsing nested JSONB field that is null.
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 2.2k
- Forks
- 379
- Avg merge
- 14m
- Merged PRs (30d)
- 8
Description
If a query returns a nested structure from a JSON(b) field, the empty field must be absent for the query to work. If the field is present and null, there is a circe exception thrown.
Example query:
sql"SELECT address->'coordinates' FROM profile"
Definition of the Coordinates and Address types:
case class Coordinates(latitude: Double, longitude: Double)
case class Address(coordinates: Option[Coordinates])
Definition of the custom mapping:
given Meta[Coordinates] = new Meta(pgDecoderGet, pgEncoderPut)
given Meta[Address] = new Meta(pgDecoderGet, pgEncoderPut)
The query works for the following contents of the address column:
NULL
{}
The query throws and exception for the following contents of the address column:
{"coordinates":null}
The exception message is: io.circe.DecodingFailure$DecodingFailureImpl: DecodingFailure at : Got value 'null' with wrong type, expecting object
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the query with the shown Coordinates, Address, and custom Meta definitions, comparing NULL, {}, and {"coordinates":null} values. Trace the decoding path that handles the nested JSONB field; done means a present null coordinates value no longer raises the reported Circe DecodingFailure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, scala
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100