Skip to content

Commit cfd06e4

Browse files
committed
fix(egress): keep a bad routing configuration from failing the auth module's load
1 parent 891e31c commit cfd06e4

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎apps/sim/lib/oauth/connect-scope.server.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ async function runInOAuthCallbackDraftScope<T>(
5959
return (await inDraftScope)(run)
6060
}
6161

62+
/**
63+
* Whether routing is on, read once while the auth config is built. A routing configuration that
64+
* fails to load counts as on, so the connector stays wrapped and the bad configuration surfaces
65+
* on its first request like every other routed call, rather than failing the auth module's load.
66+
*/
67+
function routingConfiguredAtStartup(): boolean {
68+
try {
69+
return isOutboundRoutingEnabled()
70+
} catch {
71+
return true
72+
}
73+
}
74+
6275
/**
6376
* Wraps a generic OAuth connector's code exchange and identity lookup so their vendor calls
6477
* leave through the connecting organization's egress gateway. A connector without its own
@@ -68,7 +81,7 @@ async function runInOAuthCallbackDraftScope<T>(
6881
* A deployment without outbound routing keeps the connector exactly as configured.
6982
*/
7083
export function withConnectDraftOutboundScope(config: GenericOAuthConfig): GenericOAuthConfig {
71-
if (!isOutboundRoutingEnabled()) return config
84+
if (!routingConfiguredAtStartup()) return config
7285
const { providerId, getUserInfo } = config
7386
const getToken = config.getToken ?? createOutboundCodeExchange(config)
7487
return {

0 commit comments

Comments
 (0)