{"record":{"id":"c494eba331faec91","repo":"cube-js/cube","slug":"argument-options-must-be-an-object","errorCode":null,"errorMessage":"Argument options must be an object","messagePattern":"Argument options must be an object","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-backend-native/js/index.ts","lineNumber":384,"sourceCode":"  native.setupLogger({ logger: wrapNativeFunctionWithChannelCallback(logger), logLevel, prodLogger });\n};\n\n/// Reset local to default implementation, which uses STDOUT\nexport const resetLogger = (logLevel: LogLevel): void => {\n  const native = loadNative();\n  native.resetLogger({ logLevel });\n};\n\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","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-backend-native/js/index.ts#L366-L402","documentation":"registerInterface validates its options bag before registering the SQL interface with the native addon. It throws when options is not a usable object. Note the guard `typeof options !== 'object' && options == null` is logically flawed (AND instead of OR), so null/undefined may slip past this check — but the intent is to reject non-object arguments.","triggerScenarios":"Calling registerInterface() with a non-object argument (string, number, function, boolean) — null/undefined actually bypass this particular buggy guard.","commonSituations":"Passing no/invalid config when wiring the native SQL interface in the Cube server bootstrap; a typo'd variable holding the options; destructuring mistakes where undefined was intended to be spread into an object.","solutions":["Pass a plain options object containing all required callbacks to registerInterface().","Check the calling code for typos or accidental overwriting of the options variable.","Because the guard is buggy, also verify options is not null/undefined yourself before calling."],"exampleFix":"// before\nawait registerInterface(undefined);\n\n// after\nawait registerInterface({\n  contextToApiScopes: (ctx) => ctx.apiScopes,\n  checkAuth: async (req, auth) => ({ password: auth }),\n  checkSqlAuth: async (user, password) => ({ password })\n});","handlingStrategy":"validation","validationCode":"if (typeof options !== 'object' || options === null) {\n  throw new Error('registerInterface requires a non-null options object');\n}","typeGuard":"function isSQLInterfaceOptions(o) {\n  return typeof o === 'object' && o !== null;\n}","tryCatchPattern":"try {\n  await registerInterface(options);\n} catch (e) {\n  if (e.message === 'Argument options must be an object') {\n    console.error('Pass a valid options object to registerInterface.');\n  } else throw e;\n}","preventionTips":["Always construct the options object inline at the registerInterface call site.","Check for typos or variables accidentally overwritten before the call.","Note the library's own guard is buggy (uses && not ||), so null/undefined needs your own check."],"tags":["validation","arguments","native","sql-interface"],"backgroundTag":"invalid-argument-value","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}