-
Notifications
You must be signed in to change notification settings - Fork 294
Allow insecure requests for llm apis in the playground using DANGER_ACCEPT_INVALID_CERTS #2566
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
base: canary
Are you sure you want to change the base?
Conversation
Co-authored-by: aaron <[email protected]>
Cursor Agent can help with this pull request. Just |
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
let properties = | ||
properties::resolve_properties(&client.provider, &client.unresolved_options()?, ctx)?; | ||
make_openai_client!(client, properties, "openai", dynamic) | ||
make_openai_client!(client, properties, "openai", dynamic, ctx.env_vars()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: OpenAI Client Macro Ignores Env Variable
The non-dynamic make_openai_client!
macro variant still uses create_client()
instead of create_client_with_env()
. This prevents non-dynamic OpenAI clients from respecting the DANGER_ACCEPT_INVALID_CERTS
environment variable, creating inconsistent behavior with dynamic clients.
🌿 Preview your docs: https://boundary-preview-fbcfbf70-3fa4-47fc-acdd-d579b975cbb7.docs.buildwithfern.com |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Co-authored-by: aaron <[email protected]>
Co-authored-by: aaron <[email protected]>
🌿 Preview your docs: https://boundary-preview-8f718676-8515-4d7a-a4a2-a3820ec4224f.docs.buildwithfern.com |
Pull Request Template
Thanks for taking the time to fill out this pull request!
Issue Reference
Please link to any related issues
Changes
Please describe the changes proposed in this pull request
This PR enables disabling TLS certificate verification (
curl -k
equivalent) for LLM API calls, specifically in WASM environments, by allowingDANGER_ACCEPT_INVALID_CERTS
to be passed via per-requestenv_vars
.Previously,
danger_accept_invalid_certs
was only configurable via globalstd::env
and was not available in WASM.Key Changes:
create_client_with_env
inengine/baml-runtime/src/request/mod.rs
to buildreqwest::Client
instances, accepting aHashMap<String, String>
for environment variables. This allowsDANGER_ACCEPT_INVALID_CERTS
to be read from the provided map, enabling TLS bypass in both WASM and non-WASM contexts.create_client_with_env(ctx.env_vars())
.env_vars
map when building its internalreqwest::Client
.Testing
Please describe how you tested these changes
engine/baml-runtime
were run and passed.)"DANGER_ACCEPT_INVALID_CERTS": "1"
in theenv_vars
map passed to the runtime for a specific call.)Screenshots
If applicable, add screenshots to help explain your changes
[Add screenshots here...]
PR Checklist
Please ensure you've completed these items
Additional Notes
Add any other context about the PR here
Security Warning: Disabling certificate verification exposes you to Man-in-the-Middle (MITM) attacks. This feature should only be used in trusted development or testing environments.
Slack Thread
Note
Add env-driven
create_client_with_env
and plumbenv_vars
through Anthropic, OpenAI, GoogleAI, Vertex, and AWS Bedrock to allow disabling TLS verification per request.request::create_client_with_env
andbuilder_with_env
to readDANGER_ACCEPT_INVALID_CERTS
from provided env map (WASM and non-WASM).anthropic_client.rs
), OpenAI (openai_client.rs
), GoogleAI (googleai_client.rs
), Vertex (vertex_client.rs
): construct HTTP clients withcreate_client_with_env(ctx.env_vars())
.ctx.env_vars()
.custom_http_client.rs
: addclient_with_env(...)
usingcreate_client_with_env
.aws_client.rs
: threadenv
intoclient_anyhow(...)
and usecustom_http_client::client_with_env(env)
; call sites passctx.runtime_context().env_vars()
.Written by Cursor Bugbot for commit e4da0fd. This will update automatically on new commits. Configure here.