Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.0] Supress non-UTF8 variables from pilot environment #8063

Merged
merged 2 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/pilotWrapper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
conda create -c conda-forge -c free -n python_${{ matrix.python }} python=${{ matrix.python }}
- name: run pilot wrapper test
run: |
export INVALID_UTF8_VAR=$'\xff'
cp tests/Integration/WorkloadManagementSystem/Test_GenerateAndExecutePilotWrapper.py .
eval "$(conda shell.bash hook)" && conda activate python_${{ matrix.python }}
# use github APIs to get the artifacts URLS from https://github.com/DIRACGrid/Pilot/, for those named Pilot_${{ matrix.pilot_branch }}
Expand Down
10 changes: 9 additions & 1 deletion src/DIRAC/WorkloadManagementSystem/Utilities/PilotWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,15 @@
# just logging the environment as first thing
logger.debug('===========================================================')
logger.debug('Environment of execution host\\n')
for key, val in os.environ.items():
for key, val in getattr(os, "environb", os.environ).items():
# Clean the environment of non-utf-8 characters
try:
key = key.decode("utf-8")
val = val.decode("utf-8")
except UnicodeDecodeError as e:
logger.error("Dropping %%s=%%s due to: %%s", key, val, e)
del os.environ[key]
continue
logger.debug(key + '=' + val)
logger.debug('===========================================================\\n')
Expand Down
Loading