Skip to content

Commit

Permalink
Fix double encoding of inputs in worker request
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fmeum authored and copybara-github committed Oct 28, 2024
1 parent 73e0f6a commit 89f798e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/java/com/google/devtools/build/lib/worker/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 89f798e

Please sign in to comment.