Skip to content

Commit

Permalink
chromeos: Escape non-latin characters in RDB artifacts
Browse files Browse the repository at this point in the history
Sometimes a Tast test will output a file with non-latin characters in
the file name. Since we use the filename as the artifact ID when
uploading it to RDB, and since RDB doesn't like non-latin characters,
we run into an RDB error in that case, eg:
https://chrome-swarming.appspot.com/task?id=58d4fdc3efaaf610

By replacing those characters with '?' we should be able to successfully
upload the files.
eg: https://screenshot.googleplex.com/83nKzvBpwUuWxjA

Bug: 1293539
Change-Id: I026c925b59350be7d887014cad491b6a22519049
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3437262
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Commit-Queue: Ben Pastene <bpastene@chromium.org>
Cr-Commit-Position: refs/heads/main@{#967451}
  • Loading branch information
bpastene authored and Chromium LUCI CQ committed Feb 4, 2022
1 parent 77cc74d commit 2dc9856
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion build/chromeos/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,15 @@ def get_artifacts(path):
for dirpath, _, filenames in os.walk(path):
for f in filenames:
artifact_path = os.path.join(dirpath, f)
artifacts[os.path.relpath(artifact_path, path)] = {
artifact_id = os.path.relpath(artifact_path, path)
# Some artifacts will have non-Latin characters in the filename, eg:
# 'ui_tree_Chinese Pinyin-你好.txt'. ResultDB's API rejects such
# characters as an artifact ID, so force the file name down into ascii.
# For more info, see:
# https://source.chromium.org/chromium/infra/infra/+/main:go/src/go.chromium.org/luci/resultdb/proto/v1/artifact.proto;drc=3bff13b8037ca76ec19f9810033d914af7ec67cb;l=46
artifact_id = artifact_id.encode('ascii', 'replace').decode()
artifact_id = artifact_id.replace('\\', '?')
artifacts[artifact_id] = {
'filePath': artifact_path,
}
return artifacts
Expand Down

0 comments on commit 2dc9856

Please sign in to comment.