Skip to content

Commit

Permalink
[7.4.1] Fix double encoding of inputs in worker request (#24123)
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

Commit
89f798e

Co-authored-by: Fabian Meumertzheim <[email protected]>
  • Loading branch information
bazel-io and fmeum authored Oct 29, 2024
1 parent 4aea479 commit b84f3a9
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 @@ -70,6 +70,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.decodeBytestringUtf8;
import static java.nio.charset.StandardCharsets.UTF_8;

import com.google.common.base.Stopwatch;
Expand Down Expand Up @@ -262,7 +263,10 @@ private WorkRequest createWorkRequest(
digest = ByteString.copyFromUtf8(HashCode.fromBytes(digestBytes).toString());
}

requestBuilder.addInputsBuilder().setPath(input.getExecPathString()).setDigest(digest);
requestBuilder
.addInputsBuilder()
.setPath(decodeBytestringUtf8(input.getExecPathString()))
.setDigest(digest);
}
if (workerOptions.workerVerbose) {
requestBuilder.setVerbosity(VERBOSE_LEVEL);
Expand Down

0 comments on commit b84f3a9

Please sign in to comment.