patch the network updat#100
Conversation
| data=policy.model_dump( | ||
| exclude_none=True, | ||
| exclude_unset=True, | ||
| by_alias=True, | ||
| ), |
There was a problem hiding this comment.
🔍 Behavioral change to update_network wire format may affect server-side interpretation
This PR changes the wire format of update_network requests: previously, calling update_network(SandboxNetworkPolicy(allow_internet_access=True)) would send {"allowInternetAccess": true, "allowOut": [], "denyOut": []} (because allow_out and deny_out default to [] via default_factory=list at hyperbrowser/models/sandbox.py:118-119). Now it sends only {"allowInternetAccess": true}. This is a semantic change from "replace the entire network policy" to "partially update only the specified fields." The server must support partial/patch-like semantics on this PUT endpoint for this to work correctly. The new tests confirm this is intentional, but it's worth verifying the server-side contract.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Changes
Validation
ruff checkpytestNote
Medium Risk
Changes sandbox firewall PUT payloads and could alter server-side merge behavior if the API treated omitted lists differently from empty arrays.
Overview
Fixes sandbox network update requests so partial policies do not always send
allowOut/denyOutas empty arrays.Sync and async
SandboxManager.update_networknow serializeSandboxNetworkPolicywithexclude_unset=True(along withexclude_noneand aliases). A call that only setsallowInternetAccesssends just that field, so existing outbound rules are not cleared unintentionally. Explicit empty lists are still included when the caller sets them (e.g.clear_network).Bumps the package version to 0.93.1 and adds serialization and wire-contract tests for both behaviors.
Reviewed by Cursor Bugbot for commit b201e83. Bugbot is set up for automated code reviews on this repo. Configure here.