Repository navigation
fix: Ignore empty or invalid integer environment variables - #825
Merged
Abhijeet Prasad (AbhiPrasad) merged 1 commit intoSep 29, 2026
Merged
Abhijeet Prasad (AbhiPrasad) merged 1 commit into
Abhijeet Prasad (AbhiPrasad) merged 1 commit into
Conversation
Abhijeet Prasad (AbhiPrasad)
approved these changes
Sep 29, 2026
Abhijeet Prasad (AbhiPrasad)
merged commit Sep 29, 2026
ed5dba4
into
braintrustdata:main
83 checks passed
Member
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.
Summary
Empty or non-numeric values for integer environment variables no longer raise. The SDK now keeps the default, matching the other
BRAINTRUST_*variables that already go throughBraintrustEnv.Six variables in
py/src/braintrust/logger.pywere parsed with a bareint(os.environ.get(...)):BRAINTRUST_PROMPT_CACHE_MEMORY_MAX_SIZE,BRAINTRUST_PROMPT_CACHE_DISK_MAX_SIZE,BRAINTRUST_PARAMETERS_CACHE_MEMORY_MAX_SIZEandBRAINTRUST_PARAMETERS_CACHE_DISK_MAX_SIZEare read inBraintrustState.__init__. A value such asBRAINTRUST_PROMPT_CACHE_DISK_MAX_SIZE=(declared but empty in a.envtemplate or CI config) raisesValueErrorwhen the global state is created, sobraintrust.initand the firsttracedcall fail.BRAINTRUST_MAX_GENERATOR_ITEMSis read inside the@tracedgenerator wrappers. An empty or invalid value raisesValueErrorfrom the user's own generator on its first iteration.This change adds
BraintrustEnventries for these variables and reads them with.get(default), which returns the default for empty, whitespace-only and non-numeric values.Test plan
test_traced_generators_ignore_invalid_max_items_env(sync and async generators, three invalid values) andtest_state_ignores_invalid_cache_size_env(four variables, two invalid values) inpy/src/braintrust/test_logger.py.ValueError. After the change, all 25 pass, and the fulltest_logger.pyrun reports 219 passed and 4 skipped.