Skip to content

Commit 87f2d23

Browse files
authored
Merge pull request #8067 from DIRACGridBot/cherry-pick-2-c1cfcd197-integration
[sweep:integration] Supress non-UTF8 variables from pilot environment
2 parents 50d117d + e571726 commit 87f2d23

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.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
@@ -110,7 +110,15 @@ def formatTime(self, record, datefmt=None):
110110
# just logging the environment as first thing
111111
logger.debug('===========================================================')
112112
logger.debug('Environment of execution host\\n')
113-
for key, val in os.environ.items():
113+
for key, val in getattr(os, "environb", os.environ).items():
114+
# Clean the environment of non-utf-8 characters
115+
try:
116+
key = key.decode("utf-8")
117+
val = val.decode("utf-8")
118+
except UnicodeDecodeError as e:
119+
logger.error("Dropping %%s=%%s due to: %%s", key, val, e)
120+
del os.environ[key]
121+
continue
114122
logger.debug(key + '=' + val)
115123
logger.debug('===========================================================\\n')
116124

0 commit comments

Comments
 (0)