Skip to content

Commit c1cfcd1

Browse files
authored
Merge pull request #8063 from chrisburr/pilot-non-utf8
[8.0] Supress non-UTF8 variables from pilot environment
2 parents f336dae + 4b7af95 commit c1cfcd1

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

.github/workflows/pilotWrapper.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
conda create -c conda-forge -c free -n python_${{ matrix.python }} python=${{ matrix.python }}
3636
- name: run pilot wrapper test
3737
run: |
38+
export INVALID_UTF8_VAR=$'\xff'
3839
cp tests/Integration/WorkloadManagementSystem/Test_GenerateAndExecutePilotWrapper.py .
3940
eval "$(conda shell.bash hook)" && conda activate python_${{ matrix.python }}
4041
# use github APIs to get the artifacts URLS from https://github.com/DIRACGrid/Pilot/, for those named Pilot_${{ matrix.pilot_branch }}

src/DIRAC/WorkloadManagementSystem/Utilities/PilotWrapper.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,15 @@
6868
# just logging the environment as first thing
6969
logger.debug('===========================================================')
7070
logger.debug('Environment of execution host\\n')
71-
for key, val in os.environ.items():
71+
for key, val in getattr(os, "environb", os.environ).items():
72+
# Clean the environment of non-utf-8 characters
73+
try:
74+
key = key.decode("utf-8")
75+
val = val.decode("utf-8")
76+
except UnicodeDecodeError as e:
77+
logger.error("Dropping %%s=%%s due to: %%s", key, val, e)
78+
del os.environ[key]
79+
continue
7280
logger.debug(key + '=' + val)
7381
logger.debug('===========================================================\\n')
7482

0 commit comments

Comments
 (0)