Skip to content

Fix config not forwarded to with_path in DataAPI HTTP methods#87

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-account-id-check-in-sandbox-create
Draft

Fix config not forwarded to with_path in DataAPI HTTP methods#87
Copilot wants to merge 2 commits intomainfrom
copilot/fix-account-id-check-in-sandbox-create

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 20, 2026

Sandbox.create(config=Config(account_id=...)) raised ValueError: account id is not set despite a valid config being passed, because all DataAPI HTTP methods built the request URL via self.with_path(path, query=query) without forwarding config. with_path() already accepted and correctly merged config into get_base_url() — the callers just never passed it through.

When Sandbox.__get_client() returns SandboxClient() (no config), self.config has no account_id. The call-time config reached auth/headers via _prepare_request but was silently dropped from URL construction, causing the error.

Changes

  • agentrun/utils/data_api.py — Pass config=config to self.with_path() in all HTTP methods: get, post, put, patch, delete, and their _async, _file, and _video variants
  • agentrun/utils/__data_api_async_template.py — Same fix in the async source template
  • tests/unittests/utils/test_data_api.py — Added TestDataAPIConfigForwarding with regression tests covering sync/async HTTP methods using call-time config for URL construction when the instance has no account_id
# Before: ValueError even with explicit config
api = DataAPI(resource_name="", resource_type=ResourceType.Template, config=None, namespace="sandboxes")
api.post("/", data={}, config=Config(account_id="my-account", ...))
# ValueError: account id is not set

# After: call-time config is used for URL construction
# → https://my-account.agentrun-data.cn-hangzhou.aliyuncs.com/sandboxes

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • astral.sh
    • Triggering command: /usr/bin/curl curl -LsSf REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

All HTTP methods (get, post, put, patch, delete and their async/file/video
variants) in DataAPI were calling self.with_path(path, query=query) without
forwarding the config parameter. This caused get_base_url() to use only
self.config (which was None when SandboxClient() was created without config),
ignoring any account_id provided at call time via the config argument.

Fix: pass config=config to all self.with_path() calls so the merged config
(self.config + call-time config) is used when constructing the base URL.

Apply identical fix to the __data_api_async_template.py source template.

Add regression tests in TestDataAPIConfigForwarding to verify that HTTP
methods use call-time config for URL construction even when the instance
was created without an account_id.

Agent-Logs-Url: https://github.com/Serverless-Devs/agentrun-sdk-python/sessions/04987b1e-1f19-49af-8878-9513a91f6abf

Co-authored-by: OhYee <13498329+OhYee@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix account id check in Sandbox.create method Fix config not forwarded to with_path in DataAPI HTTP methods Apr 20, 2026
Copilot AI requested a review from OhYee April 20, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sandbox.create(config=Config(...)) still raises "account id is not set" unless AGENTRUN_ACCOUNT_ID is also set in env

2 participants