Skip to content

[ci-clone] #5581: sandbox error type slug (do not merge) - #5587

Closed
mmabrouk wants to merge 1 commit into
mainfrom
ci/pr-5581-clone
Closed

[ci-clone] #5581: sandbox error type slug (do not merge)#5587
mmabrouk wants to merge 1 commit into
mainfrom
ci/pr-5581-clone

Conversation

@mmabrouk

Copy link
Copy Markdown
Member

CI clone of #5581 by @Aman-goel-04. The build / build-image jobs cannot access repo secrets on the fork PR, so they fail immediately there; this branch contains the exact same head commit pushed into the main repo so the full suite runs for real.

Do not merge. This PR will be closed without merging once the checks settle. The real PR to review and merge is #5581.

https://claude.ai/code/session_01Qitvc9dCiunLishsJYRzbp

@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview Jul 30, 2026 2:44pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Sandbox access errors now identify the specific provider that was refused.
    • Error messages clearly name the affected sandbox provider and reference the relevant configuration.
    • Existing legacy error type information remains available for compatibility.
  • Tests

    • Added coverage for provider-specific error types, default behavior, messages, status code, and legacy compatibility.

Walkthrough

LocalSandboxNotAllowedError now generates an error type containing the refused sandbox provider, retains its previous type as LEGACY_TYPE, and adds regression tests covering provider names, defaults, messages, status code, and compatibility.

Changes

Sandbox error type resolution

Layer / File(s) Summary
Dynamic error type and regression coverage
sdks/python/agenta/sdk/agents/errors.py, sdks/python/oss/tests/pytest/unit/agents/test_errors.py
LocalSandboxNotAllowedError computes provider-specific type slugs, retains LEGACY_TYPE, and tests type defaults, messages, code 403, and legacy compatibility.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • Agenta-AI/agenta issue 5575 — Describes the hardcoded sandbox error type slug addressed by this change.

Possibly related PRs

  • Agenta-AI/agenta#5581 — Contains the same provider-specific error type update and related unit tests.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title names the sandbox error type slug change and matches the main code update.
Description check ✅ Passed The description is related to the PR and correctly frames it as a CI clone of the sandbox error slug change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/pr-5581-clone

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mmabrouk
mmabrouk marked this pull request as ready for review July 30, 2026 14:44
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jul 30, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
sdks/python/agenta/sdk/agents/errors.py (1)

44-58: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Ensure the SDK validation checks pass before committing.

Run the required commands from sdks/python; py-run-tests is unavailable here, but ruff check still fails on agenta/sdk/agents/errors.py:49 for message: str = None. Type message explicitly as Optional[str]/str | None and rerun the SDK checks.

Source: Coding guidelines

🧹 Nitpick comments (1)
sdks/python/oss/tests/pytest/unit/agents/test_errors.py (1)

10-18: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the complete error type, not only substrings.

These tests can pass with an incorrectly formatted slug as long as it contains "daytona" or "local". Assert the exact expected values, including ERRORS_BASE_URL, version, namespace, and suffix, to lock down the public contract.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b336e4b7-2a97-48a7-818a-055a9046f8e9

📥 Commits

Reviewing files that changed from the base of the PR and between 221a18b and 79aae5a.

📒 Files selected for processing (2)
  • sdks/python/agenta/sdk/agents/errors.py
  • sdks/python/oss/tests/pytest/unit/agents/test_errors.py

Comment on lines +55 to +58
resolved_type = (
f"{ERRORS_BASE_URL}#v0:agent:sandbox-provider-not-allowed:{sandbox}"
)
super().__init__(code=self.code, type=resolved_type, message=resolved)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate file =="
git ls-files | rg '(^|/)agents/errors\.py$|^sdks/python/.+' || true

echo "== file outline/contents =="
if [ -f sdks/python/agenta/sdk/agents/errors.py ]; then
  wc -l sdks/python/agenta/sdk/agents/errors.py
  cat -n sdks/python/agenta/sdk/agents/errors.py
else
  echo "file not found"
fi

echo "== related usages =="
rg -n "sandbox_provider_enabled|PROVIDER|errors\." sdks/python/agenta/sdk/agents -S || true

Repository: Agenta-AI/agenta

Length of output: 39457


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== errors unit tests =="
cat -n sdks/python/oss/tests/pytest/unit/agents/test_errors.py

echo "== handler excerpt =="
cat -n sdks/python/agenta/sdk/agents/handler.py | sed -n '65,95p'

echo "== sandbox_providers excerpt =="
cat -n sdks/python/agenta/sdk/agents/sandbox_providers.py | sed -n '1,110p'

echo "== pyproject ruff/test config =="
cat -n sdks/python/pyproject.toml | sed -n '1,220p'

echo "== deterministic behavior probe =="
python3 - <<'PY'
from pathlib import Path
import ast

errors_path = Path("sdks/python/agenta/sdk/agents/errors.py")
src = errors_path.read_text()
tree = ast.parse(src)

class Finder(ast.NodeVisitor):
    def visit_Assign(self, node):
        for target in node.targets:
            if isinstance(target, ast.Name) and target.id == "KNOWN_SANDBOX_PROVIDERS":
                self.providers = ast.literal_eval(node.value)
        self.generic_visit(node)

finder = Finder()
finder.visit(tree)

def module_globals(src):
    ns = {
        "pathlib": __import__("pathlib"),
        "os": __import__("os"),
        "__name__": "__test__",
    }
    exec(src, ns)
    return ns

from sdks.ossa.sdk.agents.errors import ERRORS_BASE_URL
print("KNOWN_SANDBOX_PROVIDERS =", finder.providers)
print("ERRORS_BASE_URL =", ERRORS_BASE_URL)

ns = module_globals({"sdks.python.agenta.sdk.agents.sandbox_providers": Path("./dummy").read_text()})
# inspect relevant source text rather than import repo code
print("sdk source contains strip().lower():", ".strip().lower()" in Path("sdks/python/agenta/sdk/agents/sandbox_providers.py").read_text())
print("errors source interpolates raw sandbox:", f"resolved_type = (\n            f\"{{ERRORS_BASE_URL}}`#v0`:agent:sandbox-provider-not-allowed:{{sandbox}}\"" in src)

import sys
sys.path.insert(0, str(Path("sdks/python").resolve()))
# not running repo code; using source inspection only due to import safety policy
PY

Repository: Agenta-AI/agenta

Length of output: 10486


🏁 Script executed:

#!/bin/bash
set -euo pipefail
echo "== direct provider normalizer probe =="
python3 - <<'PY'
from pathlib import Path
from ast import parse, literal_eval

p = Path("sdks/python/agenta/sdk/agents/sandbox_providers.py")
src = p.read_text()
tree = parse(src)
known = None
for node in tree.body:
    if isinstance(node, parse().body[0].__class__) and isinstance(node, parse().body[0].__class__):
        pass
for node in tree.body:
    if isinstance(node, parse().body[0].__class__) and isinstance(node, parse().body[0].__class__):
        pass

for node in tree.body:
    if isinstance(node, parse().body[0].__class__) and isinstance(node, parse().body[0].__class__):
        pass

# simple extracted values from source text
for line in src.splitlines():
    if "KNOWN_SANDBOX_PROVIDERS =" in line:
        known = literal_eval(line.split("=", 1)[1])

print("KNOWN_SANDBOX_PROVIDERS =", known)

def sandbox_provider_enabled(provider: str):
    def enabled():
        return known
    return provider.strip().lower() in enabled()

def error_slug(provider: str):
    return f"{provider}"  # placeholder for snippet interpolation variable

print("sandbox_provider_enabled(' Daytona '):", sandbox_provider_enabled(" Daytona "))
print("slot_producer_enabled_case_preserved():", sandbox_provider_enabled("Daytona") == sandbox_provider_enabled(" dayToNa ") == True)
print("generated_slug_for_DAYTONA_with_spaces:", error_slug(" Daytona "))
print("canonical_slug:", error_slug("daytona"))
PY

echo "== read-only function normalization probe =="
python3 - <<'PY'
from pathlib import Path
from ast import parse, FunctionDef, Call, Attribute, Name, Str, Constant

text = Path("sdks/python/agenta/sdk/agents/sandbox_providers.py").read_text()
tree = parse(text)
for n in tree.body:
    if isinstance(n, FunctionDef) and n.name == "sandbox_provider_enabled":
        func = n
        break
else:
    raise SystemExit("definition not found")

for stmt in func.body:
    if isinstance(stmt, Return) and isinstance(stmt.value, Compare):
        print("comparison operator:", stmt.value.ops[0])
        left = stmt.value.left
        right = stmt.value.comparators[0]
        print("left contains strip call:", isinstance(left, Call) and isinstance(left.func, Attribute) and left.func.attr == "strip")
        print("left contains lower call:", isinstance(left, Call) and isinstance(left.func, Attribute) and left.func.attr == "lower")
        print("right contains enabled_sandbox_providers:", any(
            isinstance(m, NodeVisitor),
        ))
PY

Repository: Agenta-AI/agenta

Length of output: 334


🏁 Script executed:

#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path

providers = Path("sdks/python/agenta/sdk/agents/sandbox_providers.py").read_text()
errors = Path("sdks/python/agenta/sdk/agents/errors.py").read_text()

print("Known providers:")
for line in providers.splitlines():
    if "KNOWN_SANDBOX_PROVIDERS =" in line:
        print(" ", line)

print("\nsandbox_provider_enabled normalization:")
for line in providers.splitlines():
    if "def sandbox_provider_enabled" in line or "strip().lower" in line:
        print(" ", line)

print("\nLocalSandboxNotAllowedError uses:")
for line in errors.splitlines():
    if "LocalSandboxNotAllowedError" in line or "resolved_type" in line or "resolved = message" in line or "AGENTA_RUNNER_ENABLED" in line:
        print(" ", line)

def enabled(provider: str):
    # mirrors the current implementation in sandbox_providers.py
    return provider.strip().lower() in ("local", "daytona")

def slug(provider: str):
    # current interpolation only applies to the f-string, not to the argument
    return f"https://docs.agenta.ai/errors#v0:agent:sandbox-provider-not-allowed:{provider}"

print("\nBehavioral probe:")
for value in ["daytona", " Daytona ", "Daytona", " DAYTONA "]:
    print(f"{value!r}: enabled={enabled(value)}, error_type={slug(value)}")
PY

Repository: Agenta-AI/agenta

Length of output: 1441


Normalize the provider before constructing the error slug.

sandbox_provider_enabled() treats inputs like " Daytona " as enabled via strip().lower(), but LocalSandboxNotAllowedError interpolates the raw sandbox value into type and message. Use the normalized provider when building the error type/message so rejections don’t branch on non-canonical slugs.

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Status Destroyed (PR closed)

Updated at 2026-07-30T15:27:32.532Z

@mmabrouk

Copy link
Copy Markdown
Member Author

closing this, it was just a CI run for #5581 with repo secrets so the image builds could run. all builds passed. the real PR is #5581

@mmabrouk mmabrouk closed this Jul 30, 2026
@mmabrouk
mmabrouk deleted the ci/pr-5581-clone branch July 30, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants