cube-js/cube · error · Error
options.sql must be a function
Error message
options.sql must be a function
What it means
Configuration guard in registerInterface (cubejs-backend-native): the final check of the options validation chain; fires when options.sql is not a function. Without it the native interface cannot compile queries to SQL, meaning the registered interface would be non-functional.
Source
Thrown at packages/cubejs-backend-native/js/index.ts:416
if (typeof options.meta !== 'function') {
throw new Error('options.meta must be a function');
}
if (typeof options.stream !== 'function') {
throw new Error('options.stream must be a function');
}
if (typeof options.sqlApiLoad !== 'function') {
throw new Error('options.sqlApiLoad must be a function');
}
if (typeof options.sqlGenerators !== 'function') {
throw new Error('options.sqlGenerators must be a function');
}
if (typeof options.sql !== 'function') {
throw new Error('options.sql must be a function');
}
const native = loadNative();
return native.registerInterface({
...options,
contextToApiScopes: wrapNativeFunctionWithChannelCallback(options.contextToApiScopes),
checkAuth: wrapNativeFunctionWithChannelCallback(options.checkAuth),
checkSqlAuth: wrapNativeFunctionWithChannelCallback(options.checkSqlAuth),
sql: wrapNativeFunctionWithChannelCallback(options.sql),
meta: wrapNativeFunctionWithChannelCallback(options.meta),
stream: wrapNativeFunctionWithStream(options.stream),
sqlApiLoad: wrapNativeFunctionWithStream(options.sqlApiLoad),
sqlGenerators: wrapRawNativeFunctionWithChannelCallback(options.sqlGenerators),
logLoadEvent: wrapRawNativeFunctionWithChannelCallback(options.logLoadEvent),
canSwitchUserForSession: wrapRawNativeFunctionWithChannelCallback(options.canSwitchUserForSession),
});
};
View on GitHub (pinned to 7d981676b3)
Solutions
- Supply the sql function in the options object when calling registerInterface.
- Verify the compiler instance's sql method is being bound/passed, not invoked or misreferenced.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/cubejs-backend-native/js/index.ts:416 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/e79d564dbc6110c0.
Report an issue: GitHub.