fix: parquet fallback, non-identifier env keys, umask scoping (PR #323 follow-ups)#336
Merged
Conversation
Bug G from unaddressed PR #323 review-bot comments (Codex P1). _download_hf_dataset ran _parquet_to_jsonl outside the per-candidate try/except. If a parquet file downloaded but conversion failed (pyarrow missing or decode error), the exception propagated immediately and the JSONL candidates / API fallback were never tried. Move the conversion inside the try so a conversion failure falls through to the alternatives.
Bugs H and I from unaddressed PR #323 review-bot comments. Bug H (Codex P2): _wrap_command_with_env_file serialized env as shell 'export KEY=...' lines and sourced them. Keys that are valid process env names but not valid POSIX shell identifiers (containing '.' or '-') made '. {env_path}' return non-zero, so the user command never ran. Skip such keys with a warning; valid keys still flow through. Bug I (Cursor Medium): the 'umask 077' protecting the temp env file ran at the top of the chain and persisted into the user's command, giving files it created mode-0600 unexpectedly. Scope umask to a subshell around just the env-file write.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes three infrastructure bugs that review bots flagged on merged PR #323 but were never addressed. Each is a separate commit with a regression test whose docstring names PR #323 (per AGENTS.md).
Bug G [Codex P1] — parquet conversion outside the try, no fallback
src/benchflow/traces/huggingface.py_download_hf_dataset— the split-aware download loop caught exceptions fromhf_hub_download, but_parquet_to_jsonl(...)was outside thattry. If a parquet file downloaded butpyarrowwas missing (or parquet decoding failed), the exception propagated immediately and the JSONL candidates /_download_via_apifallback were never tried — a regression from the prior behavior that alternated formats.Fix: move the parquet conversion inside the per-candidate
try, so a conversion failure falls through to the JSONL candidates and then the API fallback.Bug H [Codex P2] — env keys that aren't valid shell identifiers
src/benchflow/sandbox/docker.py_wrap_command_with_env_file— env was serialized as shellexport {k}=...lines and sourced. Keys that are valid process env names but not valid POSIX shell identifiers (containing.or-) made. {env_path}return non-zero, so the user command never ran. The olddocker compose exec -e KEY=VALUEpath had no such constraint.Fix: only emit
exportlines for keys matching the shell-identifier grammar; skip non-identifier keys with a warning. Valid keys still flow through. Nops auxleak is reintroduced — the base64 env-file mechanism is unchanged.Bug I [Cursor Medium] —
umask 077leaks into the user commandSame function —
umask 077(set to protect the temp env file) ran at the top of thebash -cchain and persisted into the user's actual command, so files the command created got mode-0600 unexpectedly.Fix: scope
umask 077to a subshell(umask 077 && ...)around just the env-file write, restoring the default umask before the user command runs.Tests
test_parquet_conversion_failure_falls_through_to_jsonl(Bug G)test_umask_scoped_to_env_file_write(Bug I)test_non_identifier_env_keys_do_not_break_exec(Bug H)All three verified to fail against unfixed source and pass with the fixes.
CI
ruff format --check,ruff check .,ty check src/, andpytest tests/(1313 passed, 27 skipped) all pass locally.Source: unaddressed review-bot comments on PR #323.
Note
Medium Risk
Medium risk because it changes how
DockerSandbox.execmaterializes environment variables and alters HuggingFace dataset download fallback behavior; regressions would impact command execution semantics and dataset ingestion paths.Overview
Fixes two regression-prone infrastructure paths.
DockerSandbox._wrap_command_with_env_filenow scopesumask 077to a subshell so it doesn’t affect the user command, and skips non-POSIX-identifier env keys (logging a warning) so sourcing the env file can’t abort execution.HuggingFace dataset download now keeps parquet-to-JSONL conversion inside the per-candidate try/except, ensuring conversion failures (e.g., missing
pyarrow) fall through to JSONL/API fallbacks. Adds targeted regression tests for all three scenarios.Reviewed by Cursor Bugbot for commit d18cd80. Bugbot is set up for automated code reviews on this repo. Configure here.