Skip to content

Default implicit Success values can lead to unintentional retries #27

@ncreep

Description

@ncreep

Hi,
Currently the Success object provides default Success implicits for various standard types:

implicit def either[A,B]: Success[Either[A,B]] =
  Success(_.isRight)
implicit def option[A]: Success[Option[A]] =
  Success(!_.isEmpty)
implicit def tried[A]: Success[Try[A]] =
  Success(_.isSuccess)

These are available even without explicit import. I found that this can lead to unintentional retries when forgetting to add your own implicit Success value.

For example, when querying a database I have a result type of Future[Option[???]], where an empty Option stands for a missing value in the database. In some use cases, this is a legitimate return value, and retrying the query won't change anything.

The correct behavior here would be to explicitly have:

implicit val always = Success.always

in scope.

But if you forget to add this line, everything still compiles and the option implicit from the Success object is picked up, leading to unwanted retries.

I would suggest removing the implicit modifier from defs above to avoid the unintentional retries.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions