{"record":{"id":"e79d564dbc6110c0","repo":"cube-js/cube","slug":"options-sql-must-be-a-function","errorCode":null,"errorMessage":"options.sql must be a function","messagePattern":"options\\.sql must be a function","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-backend-native/js/index.ts","lineNumber":416,"sourceCode":"\n  if (typeof options.meta !== 'function') {\n    throw new Error('options.meta must be a function');\n  }\n\n  if (typeof options.stream !== 'function') {\n    throw new Error('options.stream must be a function');\n  }\n\n  if (typeof options.sqlApiLoad !== 'function') {\n    throw new Error('options.sqlApiLoad must be a function');\n  }\n\n  if (typeof options.sqlGenerators !== 'function') {\n    throw new Error('options.sqlGenerators must be a function');\n  }\n\n  if (typeof options.sql !== 'function') {\n    throw new Error('options.sql must be a function');\n  }\n\n  const native = loadNative();\n  return native.registerInterface({\n    ...options,\n    contextToApiScopes: wrapNativeFunctionWithChannelCallback(options.contextToApiScopes),\n    checkAuth: wrapNativeFunctionWithChannelCallback(options.checkAuth),\n    checkSqlAuth: wrapNativeFunctionWithChannelCallback(options.checkSqlAuth),\n    sql: wrapNativeFunctionWithChannelCallback(options.sql),\n    meta: wrapNativeFunctionWithChannelCallback(options.meta),\n    stream: wrapNativeFunctionWithStream(options.stream),\n    sqlApiLoad: wrapNativeFunctionWithStream(options.sqlApiLoad),\n    sqlGenerators: wrapRawNativeFunctionWithChannelCallback(options.sqlGenerators),\n    logLoadEvent: wrapRawNativeFunctionWithChannelCallback(options.logLoadEvent),\n    canSwitchUserForSession: wrapRawNativeFunctionWithChannelCallback(options.canSwitchUserForSession),\n  });\n};\n","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-backend-native/js/index.ts#L398-L434","documentation":"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.","triggerScenarios":"Thrown at packages/cubejs-backend-native/js/index.ts:416 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}