SyntaxError: "[object Object]" is not valid JSON on Google oauth callback

I'm trying to setup google oauth login and I'm receiving a strange error when the provider calls the callback URL. What I get in my server logs (I've added some logging in the library code):

state o2c5WeQomqhNbjem-NPwSEbeDk3Eg_J6
data {
  identifier: 'o2c5WeQomqhNbjem-NPwSEbeDk3Eg_J6',
  value: {
    callbackURL: 'http://localhost:3000',
    codeVerifier: 'jLuPd26AbFA5HtvW9mgzMZxNN28W8sK7tciEeHdQjmN_Ifqx6oUziJnZfzLUs73gE9aDq5zIOnXziatPevZ5c18qsvHeSTa25PombgxlxuNz9J30IcrLv97SL3SeZT-O',
    expiresAt: 1748903080836,
    requestSignUp: true
  },
  expiresAt: 2025-06-02T22:24:40.836Z,
  createdAt: 2025-06-02T22:14:40.836Z,
  updatedAt: 2025-06-02T22:14:40.836Z,
  id: '6m6lvQhyPJ4SctcRINSSFoK7ijIcdD3Y'
}
# SERVER_ERROR:  SyntaxError: "[object Object]" is not valid JSON
    at JSON.parse (<anonymous>)
    at parseState (file:///Users/nick/Workspace/portal/cms-frontend/node_modules/.pnpm/better-auth@1.2.8/node_modules/better-auth/dist/shared/better-auth.dn8_oqOu.mjs:83:17)
    ...


the library code at the top of the stack is this function:

async function parseState(c) {
  const state = c.query.state || c.body.state;
  const data = await c.context.internalAdapter.findVerificationValue(state);
  console.log("state", state);
  console.log("data", data);
  if (!data) {
    c.context.logger.error("State Mismatch. Verification not found", {
      state
    });
    throw c.redirect(
      `${c.context.baseURL}/error?error=please_restart_the_process`
    );
  }
  const parsedData = z.object({
     ....
  }).parse(JSON.parse(data.value));
  ...
}


when I remove the JSON.parse call in that function I am able to complete the oauth sign in sucessfully.

Info about my environment:
better-auth 1.2.8 (had the same issue on 1.2.7 and tried upgrading)
hono 4.7.8


Is this a bug in the library or in my setup? Confused how the library expects a json string there but its already an object. Thanks in advance!
Solution
Sorry, this was a problem on my side. I had the kysely plugin ParseJSONResultsPlugin enabled on the adapter
Was this page helpful?