fix(agent): expose network context
Server CI/CD / docker-image (push) Successful in 16s
Server CI/CD / deploy-fallback-log (push) Has been skipped

This commit is contained in:
2026-07-08 18:41:56 +08:00
parent 5a91da0904
commit 76cf6c32bc
4 changed files with 22 additions and 2 deletions
+16 -2
View File
@@ -404,6 +404,14 @@ def _parse_response_body(response: requests.Response) -> Any:
return {}
def _with_network_param(params: dict[str, Any] | None, network: str) -> dict[str, Any]:
params = dict(params or {})
if "network" in params or "network_name" in params or "name" in params:
return params
params["network"] = network
return params
def request_json(
ctx: RuntimeContext,
*,
@@ -417,10 +425,13 @@ def request_json(
require_username_ctx: bool = False,
) -> tuple[Any, int]:
require_server(ctx)
network = None
if require_network_ctx:
require_network(ctx)
network = require_network(ctx)
if require_username_ctx:
require_username(ctx)
if network and (params is not None or json_body is None):
params = _with_network_param(params, network)
url = f"{require_server(ctx)}/api/v1{path}"
headers = build_headers(ctx, require_auth=require_auth, require_project=require_project)
@@ -474,8 +485,11 @@ def request_bytes(
require_network_ctx: bool = False,
) -> tuple[bytes, int]:
require_server(ctx)
network = None
if require_network_ctx:
require_network(ctx)
network = require_network(ctx)
if network:
params = _with_network_param(params, network)
url = f"{require_server(ctx)}/api/v1{path}"
headers = build_headers(ctx, require_auth=require_auth, require_project=require_project)