question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nested case classes with Option types wrapped in List fails to materialize pickler

See original GitHub issue

With the API pasted below, I get the error in my client when I swap in the actual CommandMetaData case class (currently commented out):

Cannot materialize pickler for non-case class: List[model.Command]. If this is a collection, the error can refer to the class inside.
[error]     AutowireClient[Api].exec(cmds).call().toRx.map {
[error]                                        ^
[error] one error found

The API:

package model

import java.net.InetAddress
import java.util.UUID

import scala.concurrent.Future

trait Api {
  //def exec(data: List[Command])(implicit serverMeta: ImplicitMetaData): Future[String]
  def exec(data: List[Command]): Future[String]
  def poll(id: CommandId): Future[String]
}

case class CommandId(id: UUID)

object CommandId {
  def apply() = new CommandId(UUID.randomUUID)
}

//case class CommandMetaData(
//  shell: Option[String] = None,
//  containerId: Option[String] = None,
//  image: Option[String] = None,
//  user: Option[String] = None,
//  address: Option[InetAddress] = None,
//)

case class CommandMetaData()

case class ImplicitMetaData(meta: Option[CommandMetaData])

case class Command(id: CommandId, body: String, meta: CommandMetaData)

case class RunResult(out: String, err: String, exitCode: Int)
case class CommandWithResult(command: Command, result: RunResult)

And here is the wrapper function for hte exec call that failed:

  def exec(cmds: List[Command]): Rx[String] = {
    println("Verifying outer exec is called")
    AutowireClient[Api].exec(cmds).call().toRx.map { // This line fails
      case Some(attempt) => attempt match {
        case Success(output) => output
        case Failure(err) => s"Error: ${err.getCause}!"
      }
      case None => ""
    }
  }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
ochronscommented, Aug 3, 2017

Serializable has no effect on BooPickle, it’s just a Java thing 😃

And it’s probably better to use String since InetAddress is indeed not in Scala.js

1reaction
ochronscommented, Aug 3, 2017

Do you have a pickler for InetAddress in the scope?

This could also be the old and known limitation of the macro/implicit system (see #21 for a work-around using manually generated picklers) if it’s not the InetAddress.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nested case classes with Option types wrapped in List fails to ...
Nested case classes with Option types wrapped in List fails to materialize pickler. With the API pasted below, I get the error in...
Read more >
A Combination of Lists, Case Classes and Tuples does not ...
A simple combination of Lists, Cases Classes and Tuples does not compile. I see no reason, why it shouldn't work. I minimized the...
Read more >
Error updating with nested case classes in Scala Mongo DB
So I deleted my .idea files and reimported the project and the errors went away.
Read more >
suzaku-io/boopickle - Gitter
Now I have to figure out how to serialize a fix-point type. ... Pickler for my ADTs substate (that appeared in 5 different...
Read more >
Scala | Case Class and Case Object - GeeksforGeeks
A Case Class is just like a regular class, which has a feature for modeling unchangeable data. It is also constructive in pattern...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found