{"record":{"id":"87ebd0eab4b4516f","repo":"mem0ai/mem0","slug":"databricks-vector-store-requires-accesstoken-or-cl-87ebd0","errorCode":null,"errorMessage":"Databricks vector store requires accessToken or clientId/clientSecret for SQL connections.","messagePattern":"Databricks vector store requires accessToken or clientId/clientSecret for SQL connections\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/databricks.ts","lineNumber":1099,"sourceCode":"  }\n\n  private buildSqlConnectionOptions(): Record<string, any> {\n    const base = {\n      host: this.host,\n      path: this.httpPath,\n    } as Record<string, any>;\n\n    if (this.clientId && this.clientSecret) {\n      return {\n        ...base,\n        authType: \"databricks-oauth\",\n        oauthClientId: this.clientId,\n        oauthClientSecret: this.clientSecret,\n      };\n    }\n\n    if (!this.accessToken) {\n      throw new Error(\n        \"Databricks vector store requires accessToken or clientId/clientSecret for SQL connections.\",\n      );\n    }\n\n    return {\n      ...base,\n      token: this.accessToken,\n    };\n  }\n\n  /**\n   * Drop the cached session/session-promise so the next `getSession()` opens a fresh one.\n   * Called after any SQL failure below -- a stale session (expired token, dropped socket)\n   * would otherwise keep being handed out and keep failing forever.\n   */\n  private resetSession(): void {\n    this.session = undefined;\n    this._sessionPromise = undefined;","sourceCodeStart":1081,"sourceCodeEnd":1117,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/databricks.ts#L1081-L1117","documentation":"buildSqlConfig() prepares connection options for DBSQLClient. It prefers OAuth (authType 'databricks-oauth') when clientId+clientSecret are set; otherwise it requires a token for PAT auth. With neither credential present it cannot open a SQL connection and throws.","triggerScenarios":"Store configured with httpClient-only auth (API calls work via the injected client) but no accessToken and no clientId/clientSecret — the first SQL operation (createTable/insert/list) then fails here.","commonSituations":"Split auth: custom httpClient for the REST API while SQL connections still need real credentials; env var for the token named differently than the config reads; disabling PAT auth on the workspace expecting only the httpClient to be used.","solutions":["Provide accessToken in the config for PAT-based SQL connections","Or provide clientId + clientSecret so the SQL client uses databricks-oauth auth","Remember a custom httpClient only covers REST API calls — SQL warehouse connections always need credentials"],"exampleFix":"// before\nnew Databricks({ host, httpClient: myClient }); // SQL ops later fail\n\n// after\nnew Databricks({ host, httpClient: myClient, accessToken: process.env.DATABRICKS_TOKEN! });","handlingStrategy":"validation","validationCode":"if (!(cfg.clientId && cfg.clientSecret) && !cfg.accessToken) {\n  throw new Error('SQL connections need accessToken or clientId/clientSecret — httpClient only covers REST');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember a custom httpClient does not authenticate SQL sessions — always set real credentials","Include SQL credentials in config checklists, not just API auth"],"tags":["databricks","authentication","sql","configuration"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}