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 scalapb-validate setup instructions by bumping sbt-protoc #1264

Merged
merged 3 commits into from
Feb 17, 2021

Conversation

bjaglin
Copy link
Contributor

@bjaglin bjaglin commented Feb 15, 2021

Follows #1248 which turned out to give non-working instructions for scala/sbt (see scripted failure on first commit). The instructions (untouched) only work with

See scalapb/scalapb-validate#70

@akka-ci
Copy link

akka-ci commented Feb 15, 2021

Thank you for your pull request! After a quick sanity check one of the team will reply with 'OK ΤO ΤESΤ' to kick off our automated validation on Jenkins. This compiles the project, runs the tests, and checks for things like binary compatibility and source code formatting. When two team members have also manually reviewed and (perhaps after asking for some amendments) accepted your contribution, it should be good to be merged.

For more details about our contributing process, check out CONTRIBUTING.md - and feel free to ask!

@bjaglin bjaglin force-pushed the scripted-pgv branch 2 times, most recently from 938a5d2 to 70ba7a2 Compare February 15, 2021 07:34
@bjaglin bjaglin changed the title Fix PGV instructions Fix PGV setup instructions by bumping sbt-protoc Feb 15, 2021
@bjaglin bjaglin changed the title Fix PGV setup instructions by bumping sbt-protoc WIP Fix PGV setup instructions by bumping sbt-protoc Feb 15, 2021
@bjaglin bjaglin force-pushed the scripted-pgv branch 2 times, most recently from 3ec851c to 426d253 Compare February 15, 2021 15:05
@bjaglin
Copy link
Contributor Author

bjaglin commented Feb 15, 2021

Investigating [error] not found: /home/travis/.ivy2/localcom.lightbend.akka.grpc/akka-grpc-codegen_2.12/1.1.0-5-8caec5bf/ivys/ivy.xml in https://travis-ci.com/github/akka/akka-grpc/jobs/482998771 (notice the lack of path separator in /localcom...)

@raboof
Copy link
Contributor

raboof commented Feb 15, 2021

OK TO TEST

@bjaglin
Copy link
Contributor Author

bjaglin commented Feb 15, 2021

Investigating [error] not found: /home/travis/.ivy2/localcom.lightbend.akka.grpc/akka-grpc-codegen_2.12/1.1.0-5-8caec5bf/ivys/ivy.xml in https://travis-ci.com/github/akka/akka-grpc/jobs/482998771 (notice the lack of path separator in /localcom...)

The lack of path separator was a false track (and a misleading ivy log output?!). The regression was caused by a subtle behavior change exposed by thesamet/sbt-protoc@80824b0#diff-a241d0444c16c14576b308aa58a0f4f2ed70a3a6021454cd8a71882764513144R582-R583, causing an eager evaluation of the resolver, which in the case of benchmark-java/test:protocGenerate hadn't been published yet. I have updated the task dependency to reflect that, see commit message.

@bjaglin bjaglin changed the title WIP Fix PGV setup instructions by bumping sbt-protoc Fix PGV setup instructions by bumping sbt-protoc Feb 15, 2021
@bjaglin bjaglin changed the title Fix PGV setup instructions by bumping sbt-protoc Fix scalapb-validate setup instructions by bumping sbt-protoc Feb 15, 2021
@bjaglin bjaglin marked this pull request as ready for review February 15, 2021 21:45
@bjaglin bjaglin force-pushed the scripted-pgv branch 2 times, most recently from 0855562 to a648ac9 Compare February 16, 2021 00:50
@bjaglin
Copy link
Contributor Author

bjaglin commented Feb 16, 2021

cc @gontard

@@ -29,7 +29,7 @@ val root = project.in(file("."))
"org.scalatest" %% "scalatest" % "3.1.2" % "test",
"org.scalatestplus" %% "junit-4-12" % "3.1.2.0" % "test"
),
Compile / PB.generate := ((Compile / PB.generate) dependsOn (
PB.artifactResolver := (PB.artifactResolver dependsOn (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well-found!

@@ -0,0 +1 @@
> compile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there more we can test beyond 'it compiles'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I'll add a basic Main

Copy link
Contributor Author

@bjaglin bjaglin Feb 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First commit amended. I wanted to go even further and verify/show that validate_at_construction could be enabled so that clients sending invalid payloads would automatically get an error (maybe with a cutom exception handler to map scalapb.validate.ValidationFailurescalapb.validate.ValidationException to INVALID_ARGUMENT) without any specific custom code on the server implementation, but I ran into scalapb/scalapb-validate#70 (comment) so that will be for the next round.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe with a cutom exception handler to map scalapb.validate.ValidationFailure to INVALID_ARGUMENT)

that might even be reasonable to make part of the default handler

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that might even be reasonable to make part of the default handler

I got the type wrong, it's scalapb.validate.ValidationException, which extends com.google.protobuf.InvalidProtocolBufferException. Would it make sense to map InvalidProtocolBufferException to INVALID_ARGUMENT ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that makes sense to me

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scalapb/scalapb-validate@8529a55 is just out, so I took the opportunity of pushing
e4a39c6 to this PR.

End-to-end testing asserting that a payload violating a PGV rule is rejected automatically with a INVALID_ARGUMENT is not trivial in the scripted, as it requires wiring a client, a server, and forging an invalid payload, which is impossible with validate_at_construction. I guess an option would be to use Java and Java stubs (with no PGV support) as client. I won't have time to look at that in the near future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that sounds entirely reasonable!

Fixes scripted 10-scalapb-validate, see
* scalapb/ScalaPB#873 (comment)
* scalapb/scalapb-validate#70

Other changes
* cacheClassLoaders is now deprecated, see
  thesamet/sbt-protoc@2a730a4
* Forcing recompilation is no longer necessary as the cache gets
  invalidated if a sandbox genererator classpath is updated, see
  thesamet/sbt-protoc@80824b0
* The new classloader caching implementation resolves sandboxed
  generators artifacts earlier, even if they are no sources. That is
  the case for Test / protocGenerate, which was starting before
  codeGenProject / Compile / publishLocal, causing:
  > Error downloading com.lightbend.akka.grpc:akka-grpc-codegen_2.12:
  > 1.1.0-5-c5975cd5
@raboof raboof merged commit 0288da3 into akka:master Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants