Repository navigation
fix: Ignore empty BRAINTRUST_API_URL and BRAINTRUST_PROXY_URL environment variables - #2600
Open
Raphael Fakhri (RaphaelFakhri) wants to merge 1 commit into
Open
Raphael Fakhri (RaphaelFakhri) wants to merge 1 commit into
Raphael Fakhri (RaphaelFakhri) wants to merge 1 commit into
Conversation
…ironment variables
This branch has not been deployed
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
BRAINTRUST_API_URLandBRAINTRUST_PROXY_URLenvironment variables are now ignored, and the SDK uses the API and proxy URLs from the organization's login response.The logger reads both variables with
iso.getEnv(name) ?? org.api_url.??only falls back forundefined, so an empty value is used as the URL. Empty values are common: Docker Compose setsBRAINTRUST_API_URL: ${BRAINTRUST_API_URL}to""when the host variable is unset, and GitHub Actions does the same for an undefined${{ vars.* }}. The effects:BRAINTRUST_API_URL=makeslogin(),initLogger()andinit()fail withUnable to log into any organization with the provided credential., even though the credential is valid.BRAINTRUST_API_URL=makesloadPrompt()andloadParameters()with an explicitapiKeyfail with the same error.BRAINTRUST_PROXY_URL=setsstate.proxyUrlto"", so proxy requests go to the API URL instead of the organization's proxy URL, andBraintrustState.serialize()throwsCannot serialize BraintrustState without all login attributes.This change uses
||for these lookups, which matches how the same file already readsBRAINTRUST_APP_URLandBRAINTRUST_APP_PUBLIC_URL. The Python SDK already treats empty values of these variables as unset.Test plan
js/src/logger.test.ts:loginToStatewith emptyBRAINTRUST_API_URLandBRAINTRUST_PROXY_URLuses the organization'sapi_urlandproxy_url.loadPromptwith an explicit API key and an emptyBRAINTRUST_API_URLsends the prompt request to the organization'sapi_url.Unable to log into any organization with the provided credential.After the change, both pass, and all 133 tests in the file pass.