Skip to content

Commit 53d785b

Browse files
Enrich local BEP upload errors with file path and digest possible. (#18481)
Closes #18461. PiperOrigin-RevId: 534006853 Change-Id: I256297fe494393f13e178bf74f967b9b691db281 Co-authored-by: Benjamin Peterson <[email protected]>
1 parent c422565 commit 53d785b

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/main/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploader.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ private Single<List<PathMetadata>> queryRemoteCache(
256256
return toSingle(() -> remoteCache.findMissingDigests(context, digestsToQuery), executor)
257257
.onErrorResumeNext(
258258
error -> {
259-
reporterUploadError(error);
259+
reportUploadError(error, null, null);
260260
// Assuming all digests are missing if failed to query
261261
return Single.just(ImmutableSet.copyOf(digestsToQuery));
262262
})
@@ -267,13 +267,19 @@ private Single<List<PathMetadata>> queryRemoteCache(
267267
});
268268
}
269269

270-
private void reporterUploadError(Throwable error) {
270+
private void reportUploadError(Throwable error, Path path, Digest digest) {
271271
if (error instanceof CancellationException) {
272272
return;
273273
}
274274

275-
String errorMessage =
276-
"Uploading BEP referenced local files: " + grpcAwareErrorMessage(error, verboseFailures);
275+
String errorMessage = "Uploading BEP referenced local file";
276+
if (path != null) {
277+
errorMessage += " " + path;
278+
}
279+
if (digest != null) {
280+
errorMessage += " " + digest;
281+
}
282+
errorMessage += ": " + grpcAwareErrorMessage(error, verboseFailures);
277283

278284
reporter.handle(Event.warn(errorMessage));
279285
}
@@ -298,11 +304,11 @@ private Single<List<PathMetadata>> uploadLocalFiles(
298304
path.isDirectory(),
299305
// set remote to true so the PathConverter will use bytestream://
300306
// scheme to convert the URI for this file
301-
/*remote=*/ true,
307+
/* remote= */ true,
302308
path.isOmitted()))
303309
.onErrorResumeNext(
304310
error -> {
305-
reporterUploadError(error);
311+
reportUploadError(error, path.getPath(), path.getDigest());
306312
return Single.just(path);
307313
});
308314
})
@@ -329,7 +335,7 @@ private Single<PathConverter> upload(Set<Path> files) {
329335
try {
330336
return readPathMetadata(file);
331337
} catch (IOException e) {
332-
reporterUploadError(e);
338+
reportUploadError(e, file, null);
333339
return new PathMetadata(
334340
file,
335341
/* digest= */ null,

src/test/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploaderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ public void onCompleted() {
333333

334334
assertThat(eventHandler.getEvents()).isNotEmpty();
335335
assertThat(eventHandler.getEvents().get(0).getMessage())
336-
.contains("Uploading BEP referenced local files: ");
336+
.contains("Uploading BEP referenced local file /file");
337337

338338
artifactUploader.release();
339339

0 commit comments

Comments
 (0)