Skip to content

Commit 662cd15

Browse files
improvement(self-host): centralize capability resolution
1 parent 9d6c317 commit 662cd15

26 files changed

Lines changed: 1819 additions & 879 deletions

apps/docs/content/docs/en/platform/self-hosting/object-storage.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ Sim stores every uploaded file — knowledge base documents, chat attachments, e
2323

2424
## How the backend is selected
2525

26-
Sim picks the backend automatically from environment variables — there is no explicit "provider" flag. The logic, in order of precedence:
26+
Set `STORAGE_PROVIDER` to `local`, `s3`, `azure`, or `gcs` to select a backend explicitly. When it is unset, Sim infers the backend from the configured environment variables in this order:
2727

2828
1. **Azure Blob** — used if `AZURE_STORAGE_CONTAINER_NAME` is set **and** either (`AZURE_ACCOUNT_NAME` + `AZURE_ACCOUNT_KEY`) or `AZURE_CONNECTION_STRING` is set.
2929
2. **AWS S3** — used if `S3_BUCKET_NAME` **and** `AWS_REGION` are set (and Azure is not configured).
3030
3. **Google Cloud Storage** — used if `GCS_BUCKET_NAME` is set (and neither Azure nor S3 is configured).
3131
4. **Local disk** — the fallback when none is configured.
3232

33-
If more than one backend is configured, the first match in that order wins. Set only the variables for the backend you intend to use.
33+
If `STORAGE_PROVIDER` is unset, Sim skips incomplete backends and uses the first ready match in that order. A higher-priority backend with its required fields present but invalid supplied values fails fast instead of silently falling through. An explicit `STORAGE_PROVIDER` takes precedence and must be valid and complete.
3434

3535
## Set up AWS S3
3636

apps/sim/.env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ API_ENCRYPTION_KEY=your_api_encryption_key # Use `openssl rand -hex 32` to gener
3232
CRON_SECRET=your_cron_secret # Use `openssl rand -hex 32` to generate. Authenticates the scheduler against the background job endpoints (scheduled workflows, polling triggers, connector syncs)
3333

3434
# Email Provider (Optional)
35-
# Configure ONE provider — the mailer auto-detects in priority order:
36-
# Resend → AWS SES → SMTP → Azure Communication Services → Gmail. If none
37-
# are configured, emails are logged to console instead.
35+
# Configure one or more providers. Every configured provider stays active and is
36+
# tried in order: Resend → AWS SES → SMTP → Azure Communication Services → Gmail.
37+
# If none are configured, emails are logged to console instead.
3838
#
3939
# Resend
4040
# RESEND_API_KEY= # API key from https://resend.com

apps/sim/lib/core/config/env-capabilities.server.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,35 @@
55
*/
66
import { env } from '@/lib/core/config/env'
77
import {
8+
ASYNC_JOBS_CAPABILITY,
9+
CACHE_CAPABILITY,
810
type ConfiguredOAuthClient,
911
type FallbackCapabilityDefinition,
1012
inspectOAuthClientCapability,
1113
type OAuthClientCapabilityField,
1214
type OAuthClientCapabilityId,
15+
requireCapability,
1316
requireOAuthClientCapability,
14-
resolveAsyncJobsProvider,
15-
resolveCacheProvider,
16-
resolveSandboxProviderId,
17-
resolveSelectedCapability,
17+
SANDBOX_CAPABILITY,
1818
STORAGE_CAPABILITY,
1919
type WireFallbackOptions,
2020
wireFallback,
2121
} from '@/lib/core/config/env-capabilities'
2222

2323
export function getConfiguredStorageProviderId() {
24-
return resolveSelectedCapability(STORAGE_CAPABILITY, env).providerId
24+
return requireCapability(STORAGE_CAPABILITY, env).providerId
2525
}
2626

2727
export function getConfiguredSandboxProviderId() {
28-
return resolveSandboxProviderId(env)
28+
return requireCapability(SANDBOX_CAPABILITY, env).providerId
2929
}
3030

3131
export function getConfiguredAsyncJobsProvider() {
32-
return resolveAsyncJobsProvider(env)
32+
return requireCapability(ASYNC_JOBS_CAPABILITY, env).providerId
3333
}
3434

3535
export function getConfiguredCacheProvider() {
36-
return resolveCacheProvider(env)
36+
return requireCapability(CACHE_CAPABILITY, env).providerId
3737
}
3838

3939
export function inspectConfiguredOAuthClient(serviceId: string) {

0 commit comments

Comments
 (0)