Skip to content

Commit 8a22ae4

Browse files
anticorrelatorcephalization
authored andcommitted
fix(sandbox): convert rebased inline-evaluator preview call site to async factory
Base PR #12690 added _resolve_inline_code_evaluator_backend with a sync call to get_or_create_backend. Our branch made that factory async with required session/decrypt params for DB-backed credential resolution, so the call site needs the same conversion applied at the other two sites: await, session+decrypt, MissingSecretError/UnsupportedOperation/ ValidationError mapping to BadRequest, and admin-provider-wins merge order.
1 parent 34b8d6d commit 8a22ae4

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

src/phoenix/server/api/mutations/chat_mutations.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ async def _resolve_inline_code_evaluator_backend(
9898
sandbox_config_id: Optional[strawberry.relay.GlobalID],
9999
language: str,
100100
) -> tuple[Any, Optional[int]]:
101-
from phoenix.server.sandbox import get_or_create_backend
101+
from phoenix.server.sandbox import MissingSecretError, get_or_create_backend
102+
from phoenix.server.sandbox.types import UnsupportedOperation
102103

103104
if sandbox_config_id is None:
104105
raise BadRequest(
@@ -140,12 +141,27 @@ async def _resolve_inline_code_evaluator_backend(
140141
if provider_language_row is not None and provider_language_row.name != language:
141142
raise BadRequest("Sandbox provider language does not match code evaluator language")
142143

144+
# Admin-authored provider config wins over user-authored
145+
# SandboxConfig.config on key collision — consistent with
146+
# the factory's credentials-win merge order.
143147
merged_config = {
144-
**provider.config,
145148
**sandbox_cfg.config,
149+
**provider.config,
146150
}
147151
backend_type = provider.backend_type
148-
sandbox_backend = get_or_create_backend(backend_type, config=merged_config)
152+
try:
153+
sandbox_backend = await get_or_create_backend(
154+
backend_type,
155+
config=merged_config,
156+
session=session,
157+
decrypt=info.context.decrypt,
158+
)
159+
except (
160+
MissingSecretError,
161+
UnsupportedOperation,
162+
ValidationError,
163+
) as exc:
164+
raise BadRequest(str(exc))
149165

150166
if sandbox_backend is None:
151167
raise BadRequest(

0 commit comments

Comments
 (0)