Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix false-negatives for codec registration checker plugin #184

Open
LukaszKontowski opened this issue Jul 7, 2022 · 3 comments
Open

Fix false-negatives for codec registration checker plugin #184

LukaszKontowski opened this issue Jul 7, 2022 · 3 comments
Labels
bug Something isn't working codecs Relates to useful/missing Circe codec (regardless of Akka serialization) nice to have Not very strictly needed for ASH to be usable

Comments

@LukaszKontowski
Copy link
Contributor

LukaszKontowski commented Jul 7, 2022

In specific scenarios, codec registration checker plugin does not find missing codec registrations - i.e. when using sbt incremental compilation. Example scenario with explanation - steps to be performed on a project that uses ASH:

  1. sbt compile on existing code (fresh compilation on all files) - compilation succeeds - OK
  2. add new top level serializable class (in a separate file) and do not register it in serializer
  3. sbt compile - compilation succeeds - NOT OK

If we would perform only steps 2. and 3. - sbt compile would end in an error (which is what we want) saying that there are missing codec registrations. So, this is an issue with incremental compilation. The reason of this issue is to fix such "false negatives". Compilation should never succeed for situations as described above - whether this is full compilation on all sources - or just an incremental compilation on one or more added files.

@LukaszKontowski LukaszKontowski added bug Something isn't working codecs Relates to useful/missing Circe codec (regardless of Akka serialization) nice to have Not very strictly needed for ASH to be usable labels Jul 7, 2022
@LukaszKontowski
Copy link
Contributor Author

LukaszKontowski commented Jul 7, 2022

This issue is related to the way CirceAkkaSerializer (CAS) works. For CAS the problem is that:

  • codec registration checker plugin searches for org.virtuslab.ash.circe.Registration occurences in the compiled source
  • CAS real registrations are based on the codecs collection - which must be defined in the CAS implementation in the client's code in a file that contains the top-level Serializer (let's call this file A.scala)
  • In situations as described above - if we add a new file - B.scala with new Registrations - it would look OK to the plugin - because it has found Registrations of types that were to be checked
  • However - as A.scala is not compiled and in effect it is not checked by the plugin - plugin will not find this missing Registration in A.scala

In fact - we would need to force compilation of the A.scala file in such situations to catch such errors.

@PawelLipski
Copy link
Collaborator

org.virtuslab.ash.circe.enable-missing-codecs-check config key can be removed if this is done, right?

@LukaszKontowski
Copy link
Contributor Author

Yes, and connected part of logic - method checkSerializableTypesForMissingCodec

@PawelLipski PawelLipski changed the title Nice to have: fix false-negatives for codec registration checker plugin Fix false-negatives for codec registration checker plugin Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working codecs Relates to useful/missing Circe codec (regardless of Akka serialization) nice to have Not very strictly needed for ASH to be usable
Projects
None yet
Development

No branches or pull requests

2 participants