Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions platform/packages/api/src/provisioning/sandbox-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type WorkerSettings = {
namespace_id?: string;
service?: string;
entrypoint?: string;
props?: Record<string, unknown>;
}>;
};

Expand Down Expand Up @@ -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);
Expand Down
12 changes: 11 additions & 1 deletion platform/packages/api/test/integration/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1620,8 +1620,18 @@ export function mockCfApi(overrides: Partial<CfApiMocks> = {}): 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 },
Expand Down
Loading