docs: add SDK examples for updateNetwork in proxy configuration#583
Conversation
Update the 'Update proxy configuration' section to showcase the new SandboxInstance.updateNetwork (TypeScript) and SandboxInstance.update_network (Python) SDK methods alongside the existing cURL example. Refs: ENG-2665 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Needs attention — 1 issue in 1 file
The Python example passes a raw dict with camelCase keys ("allowedDomains", "routing") to SandboxUpdateNetwork(network={...}). If the SDK's Pydantic model uses snake_case field names (the Python convention), this will silently ignore or reject those keys at runtime — readers copying this example verbatim will get an empty/incorrect config. The PR checklist correctly flags signature verification as required before merge; that check must confirm the dict key casing is actually valid for the Python SDK.
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<assessment>
The Python example passes a raw `dict` with camelCase keys (`"allowedDomains"`, `"routing"`) to `SandboxUpdateNetwork(network={...})`. If the SDK's Pydantic model uses snake_case field names (the Python convention), this will silently ignore or reject those keys at runtime — readers copying this example verbatim will get an empty/incorrect config. The PR checklist correctly flags signature verification as required before merge; that check must confirm the dict key casing is actually valid for the Python SDK.
</assessment>
<file name="Sandboxes/Proxy.mdx">
<issue location="Sandboxes/Proxy.mdx:251">
Python dict keys use camelCase (`allowedDomains`, `routing`) where the Python SDK likely expects snake_case (`allowed_domains`). If `SandboxUpdateNetwork` is a Pydantic model without camelCase aliases, these keys will be silently dropped, producing an empty network config.
</issue>
</file>
Tag @mendral-app with feedback or questions. View session
| SandboxUpdateNetwork(network={ | ||
| "allowedDomains": ["api.stripe.com", "api.openai.com", "api.anthropic.com"], | ||
| "proxy": { | ||
| "routing": [ | ||
| { | ||
| "destinations": ["api.stripe.com"], | ||
| "headers": {"Authorization": "Bearer {{SECRET:stripe-key}}"}, | ||
| "secrets": {"stripe-key": "sk_live_REPLACE_WITH_YOUR_KEY"}, | ||
| }, | ||
| { | ||
| "destinations": ["api.anthropic.com"], | ||
| "headers": {"x-api-key": "{{SECRET:anthropic-key}}"}, | ||
| "secrets": {"anthropic-key": "REPLACE_WITH_YOUR_ANTHROPIC_KEY"}, | ||
| }, | ||
| ], | ||
| }, | ||
| }), | ||
| ) |
There was a problem hiding this comment.
bug (P2): Python dict keys use camelCase (allowedDomains, routing) where the Python SDK likely expects snake_case (allowed_domains). If SandboxUpdateNetwork is a Pydantic model without camelCase aliases, these keys will be silently dropped, producing an empty network config.
Suggested change
| SandboxUpdateNetwork(network={ | |
| "allowedDomains": ["api.stripe.com", "api.openai.com", "api.anthropic.com"], | |
| "proxy": { | |
| "routing": [ | |
| { | |
| "destinations": ["api.stripe.com"], | |
| "headers": {"Authorization": "Bearer {{SECRET:stripe-key}}"}, | |
| "secrets": {"stripe-key": "sk_live_REPLACE_WITH_YOUR_KEY"}, | |
| }, | |
| { | |
| "destinations": ["api.anthropic.com"], | |
| "headers": {"x-api-key": "{{SECRET:anthropic-key}}"}, | |
| "secrets": {"anthropic-key": "REPLACE_WITH_YOUR_ANTHROPIC_KEY"}, | |
| }, | |
| ], | |
| }, | |
| }), | |
| ) | |
| await SandboxInstance.update_network( | |
| "my-sandbox", | |
| SandboxUpdateNetwork(network={ | |
| "allowed_domains": ["api.stripe.com", "api.openai.com", "api.anthropic.com"], | |
| "proxy": { | |
| "routing": [ | |
| { | |
| "destinations": ["api.stripe.com"], | |
| "headers": {"Authorization": "Bearer {{SECRET:stripe-key}}"}, | |
| "secrets": {"stripe-key": "sk_live_REPLACE_WITH_YOUR_KEY"}, | |
| }, | |
| { | |
| "destinations": ["api.anthropic.com"], | |
| "headers": {"x-api-key": "{{SECRET:anthropic-key}}"}, | |
| "secrets": {"anthropic-key": "REPLACE_WITH_YOUR_ANTHROPIC_KEY"}, | |
| }, | |
| ], | |
| }, | |
| }), | |
| ) |
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Sandboxes/Proxy.mdx, line 251:
<issue>
Python dict keys use camelCase (`allowedDomains`, `routing`) where the Python SDK likely expects snake_case (`allowed_domains`). If `SandboxUpdateNetwork` is a Pydantic model without camelCase aliases, these keys will be silently dropped, producing an empty network config.
</issue>
There was a problem hiding this comment.
Not a bug — the Python SDK integration tests use camelCase dict keys:
SandboxUpdateNetwork(network={"allowedDomains": ["httpbin.org", "*.httpbin.org"]})
SandboxUpdateNetwork(network={"forbiddenDomains": ["httpbin.org", "*.httpbin.org"]})See tests/integration/core/sandbox/test_network.py. The network parameter accepts a Union[SandboxNetwork, Dict[str, Any]] — when a dict is passed, it goes through the API client which uses camelCase field names matching the REST API schema.
Summary
Updates the "Update proxy configuration" section in
Sandboxes/Proxy.mdxto showcase the new SDK methods:SandboxInstance.updateNetwork(sandboxName, { network: {...} })SandboxInstance.update_network(sandbox_name, SandboxUpdateNetwork(network={...}))The existing cURL example is preserved and wrapped in a
<CodeGroup>alongside the new SDK examples.Refs: ENG-2665
Review & Testing Checklist for Human
updateNetworkmethod signature from sdk-typescript#313update_networkmethod signature from sdk-python#150<CodeGroup>tabs display correctlyNotes
The SDK methods were added in sdk-typescript#313 and sdk-python#150.
Link to Devin session: https://app.devin.ai/sessions/0f7a2e36861d46ecb6c11d4749803173
Requested by: @Joffref
Note
Adds TypeScript and Python SDK examples for
updateNetwork/update_networkto the "Update proxy configuration" section, wrapping all three examples (TypeScript, Python, cURL) in a<CodeGroup>component.Written by Mendral for commit 7640167.