From 308875a9eb8d9483dd744a9d443cccda0b6d287b Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Mon, 28 Oct 2024 13:50:47 -0700 Subject: [PATCH] Fix double encoding of inputs in worker request Since `WorkRequest` encodes strings as UTF-8, Bazel's internal string encoding of file paths needs to be undone before passing them to the protobuf builder. Closes #23924. PiperOrigin-RevId: 690737819 Change-Id: I3eb341c05e045c75ac004da57e1f46f3587a6810 --- src/main/java/com/google/devtools/build/lib/worker/BUILD | 1 + .../google/devtools/build/lib/worker/WorkerSpawnRunner.java | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/google/devtools/build/lib/worker/BUILD b/src/main/java/com/google/devtools/build/lib/worker/BUILD index 67a4914e2cf60d..067c20001721df 100644 --- a/src/main/java/com/google/devtools/build/lib/worker/BUILD +++ b/src/main/java/com/google/devtools/build/lib/worker/BUILD @@ -75,6 +75,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/exec/local", "//src/main/java/com/google/devtools/build/lib/profiler", "//src/main/java/com/google/devtools/build/lib/sandbox:sandbox_helpers", + "//src/main/java/com/google/devtools/build/lib/util:string", "//src/main/java/com/google/devtools/build/lib/util/io", "//src/main/java/com/google/devtools/build/lib/vfs", "//src/main/java/com/google/devtools/build/lib/vfs:pathfragment", diff --git a/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java index a88548fd31d1d2..f9bd86ba820d0b 100644 --- a/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java @@ -15,6 +15,7 @@ package com.google.devtools.build.lib.worker; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.devtools.build.lib.util.StringUtil.reencodeInternalToExternal; import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.base.Stopwatch; @@ -274,7 +275,10 @@ private WorkRequest createWorkRequest( digest = ByteString.copyFromUtf8(HashCode.fromBytes(digestBytes).toString()); } - requestBuilder.addInputsBuilder().setPath(input.getExecPathString()).setDigest(digest); + requestBuilder + .addInputsBuilder() + .setPath(reencodeInternalToExternal(input.getExecPathString())) + .setDigest(digest); } if (workerOptions.workerVerbose) { requestBuilder.setVerbosity(VERBOSE_LEVEL);