From 244d079f50d1a097d9bd857666f24c2b928ee78a Mon Sep 17 00:00:00 2001 From: LongYinan Date: Wed, 30 Sep 2026 19:57:52 +0800 Subject: [PATCH] fix(platform): accept sandbox controllers without echoed binding props Cloudflare applies service binding `props` at runtime but omits them from the script `/settings` response. The controller assertion required them, so every managed Sandbox deploy failed on its own freshly created controller. Keep the service and entrypoint checks; the plain-text identity bindings from the same upload still bind the deployment. The Cloudflare mock now returns the real `/settings` shape. Fixes #344 Co-Authored-By: Claude Opus 5.5 (1M context) --- .../api/src/provisioning/sandbox-controller.ts | 13 +++---------- platform/packages/api/test/integration/helpers.ts | 12 +++++++++++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/platform/packages/api/src/provisioning/sandbox-controller.ts b/platform/packages/api/src/provisioning/sandbox-controller.ts index 5005d2b33..010f17c90 100644 --- a/platform/packages/api/src/provisioning/sandbox-controller.ts +++ b/platform/packages/api/src/provisioning/sandbox-controller.ts @@ -33,7 +33,6 @@ type WorkerSettings = { namespace_id?: string; service?: string; entrypoint?: string; - props?: Record; }>; }; @@ -134,18 +133,12 @@ function assertConfiguration( throw new Error(`Sandbox controller binding ${name} differs from this deployment.`); } } + // Cloudflare does not return service binding `props` from `/settings`. The + // plain-text bindings checked above come from the same upload as the props. const control = settings.bindings.find( (binding) => binding.type === 'service' && binding.name === '__VOID_SANDBOX_CONTROL', ); - if ( - control?.service !== apiService || - control.entrypoint !== 'SandboxControl' || - !control.props || - control.props.projectId !== identity.projectId || - control.props.deploymentId !== identity.deploymentId || - control.props.userId !== identity.userId || - control.props.slug !== identity.slug - ) { + if (control?.service !== apiService || control.entrypoint !== 'SandboxControl') { throw new Error('Sandbox controller authority binding differs from this deployment.'); } namespaceId(settings); diff --git a/platform/packages/api/test/integration/helpers.ts b/platform/packages/api/test/integration/helpers.ts index bc502ae17..b632e223c 100644 --- a/platform/packages/api/test/integration/helpers.ts +++ b/platform/packages/api/test/integration/helpers.ts @@ -1620,8 +1620,18 @@ export function mockCfApi(overrides: Partial = {}): MockCfApiHandle if (method === 'GET' && url.endsWith('/settings')) { const name = parseScriptNameFromUrl(url); const script = name ? state.hostScripts.get(name) : undefined; + // Cloudflare accepts `props` on a service binding upload and applies + // them at runtime, but never echoes them from `/settings`. return script - ? cfSuccess({ bindings: script.bindings }) + ? cfSuccess({ + bindings: script.bindings.map((binding) => { + if (binding.type !== 'service') { + return binding; + } + const { props: _props, ...rest } = binding; + return { ...rest, environment: 'production' }; + }), + }) : Response.json( { success: false, errors: [{ code: 10007, message: 'script not found' }] }, { status: 404 },