cube-js/cube · error
contextToDataSourceId has been deprecated and removed. Use…
Error message
contextToDataSourceId has been deprecated and removed. Use contextToOrchestratorId instead.
What it means
The contextToDataSourceId option was deprecated and removed from Cube Server. Its constructor now hard-fails if that option is present, directing users to contextToOrchestratorId, which controls per-context orchestrator (and implicitly data source) routing.
Solutions
- Remove contextToDataSourceId from the server options
- Implement contextToOrchestratorId(options) returning a stable per-context/per-tenant orchestrator id instead
- If data source routing is needed, return a data-source-derived id from contextToOrchestratorId
- Consult the Cube docs on multi-tenancy for the current recommended pattern
Example fix
// before
new CubeServer({
contextToDataSourceId: (ctx) => ctx.tenantId
});
// after
new CubeServer({
contextToOrchestratorId: (ctx) => ctx.tenantId
}); Defensive patterns
Strategy: validation
When it happens
Trigger: Passing contextToDataSourceId in the options object when constructing the Cube server core (new CubeServer / CubeCore), typically carried over from an older codebase.
Common situations: Upgrading Cube from a version where contextToDataSourceId was valid; copy-pasted config from old examples or blog posts; multi-tenant setups that routed orchestrators per data source via the old hook.
Related errors
- A user-defined contextToApiScopes function returns an…
- A user-defined contextToApiScopes function returns a wrong…
- Access policy cannot have both 'group' and 'groups'…
- API URL is empty
- Auth isn't set
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/aad02bb42d63c241.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cubejs-server-core/src/core/server.ts:220
this.scheduledRefreshTimeZones = wrapToFnIfNeeded(this.options.scheduledRefreshTimeZones || []);
this.compilerCache = new LRUCache<string, CompilerApi>({
max: this.options.compilerCacheSize || 250,
ttl: this.options.maxCompilerCacheKeepAlive,
updateAgeOnGet: this.options.updateCompilerCacheKeepAlive,
// needed to clear the setInterval timer for proactive cache internal cleanups
dispose: (v) => v.dispose(),
});
if (this.options.contextToAppId) {
this.contextToAppId = this.options.contextToAppId;
this.standalone = false;
}
this.contextAcceptor = this.createContextAcceptor();
if (this.options.contextToDataSourceId) {
throw new Error('contextToDataSourceId has been deprecated and removed. Use contextToOrchestratorId instead.');
}
this.contextToOrchestratorId = this.options.contextToOrchestratorId || (() => 'STANDALONE');
this.contextToCubeStoreRouterId = this.options.contextToCubeStoreRouterId;
// proactively free up old cache values occasionally
if (this.options.maxCompilerCacheKeepAlive) {
this.maxCompilerCacheKeep = setInterval(
() => this.compilerCache.purgeStale(),
this.options.maxCompilerCacheKeepAlive
);
}
this.startScheduledRefreshTimer();
this.event = async (event, props: LoggerFnParams) => {
if (!this.options.telemetry) {
return;View on GitHub (pinned to 7d981676b3)