{"record":{"id":"42e202d6e0fe4eb2","repo":"cube-js/cube","slug":"options-checkauth-must-be-a-function","errorCode":null,"errorMessage":"options.checkAuth must be a function","messagePattern":"options\\.checkAuth must be a function","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-backend-native/js/index.ts","lineNumber":392,"sourceCode":"\nexport const isFallbackBuild = (): boolean => {\n  const native = loadNative();\n  return native.isFallbackBuild();\n};\n\nexport type SqlInterfaceInstance = { __typename: 'sqlinterfaceinstance' };\n\nexport const registerInterface = async (options: SQLInterfaceOptions): Promise<SqlInterfaceInstance> => {\n  if (typeof options !== 'object' && options == null) {\n    throw new Error('Argument options must be an object');\n  }\n\n  if (typeof options.contextToApiScopes !== 'function') {\n    throw new Error('options.contextToApiScopes must be a function');\n  }\n\n  if (typeof options.checkAuth !== 'function') {\n    throw new Error('options.checkAuth must be a function');\n  }\n\n  if (typeof options.checkSqlAuth !== 'function') {\n    throw new Error('options.checkSqlAuth must be a function');\n  }\n\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","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-backend-native/js/index.ts#L374-L410","documentation":"registerInterface requires a checkAuth function used to authenticate REST API requests through the native interface. If it is missing or not callable, authentication cannot be performed, so the registration is rejected.","triggerScenarios":"Calling registerInterface() with an options object whose checkAuth property is absent, null, or not a function.","commonSituations":"Omitting checkAuth while porting an existing Cube config to the native interface; renaming the auth handler but not updating this wiring; using a JWT-only config that assumed a default handler.","solutions":["Provide a checkAuth function, e.g. async (req, authorization) => ({ password: authorization }).","Reuse your existing api-gateway checkAuth implementation and pass it into the options.","Verify the function reference is defined at the time registerInterface is called (no hoisting/import issues)."],"exampleFix":"// before\nawait registerInterface({ contextToApiScopes, checkSqlAuth, meta, stream });\n\n// after\nawait registerInterface({\n  contextToApiScopes,\n  checkAuth: async (req, authorization) => ({ password: authorization }),\n  checkSqlAuth, meta, stream\n});","handlingStrategy":"validation","validationCode":"if (typeof options.checkAuth !== 'function') {\n  throw new Error('options.checkAuth must be provided as a function');\n}","typeGuard":"function hasCheckAuth(o) {\n  return typeof o?.checkAuth === 'function';\n}","tryCatchPattern":"try {\n  await registerInterface(options);\n} catch (e) {\n  if (e.message === 'options.checkAuth must be a function') {\n    console.error('Provide checkAuth: async (req, authorization) => ({ password: authorization }).');\n  } else throw e;\n}","preventionTips":["Reuse the checkAuth handler from your existing api-gateway config.","Validate the full options object once in a shared helper before registering.","Use TypeScript's SQLInterfaceOptions type to catch missing callbacks at build time."],"tags":["validation","callback","authentication","sql-interface"],"backgroundTag":"missing-required-callback","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}