Skip to content

OAuthProfileParseError when no profile picture set #13042

@crzdg

Description

@crzdg

Environment

  System:
    OS: Linux 6.6 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (4) x64 Intel(R) Xeon(R) Gold 6248R CPU @ 3.00GHz
    Memory: 28.04 GB / 31.28 GB
    Container: Yes
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 22.16.0 - /usr/local/bin/node
    Yarn: 1.22.22 - /usr/local/bin/yarn
    npm: 10.9.2 - /usr/local/bin/npm
    bun: 1.2.8 - /usr/local/bin/bun

next: 15.3.0
react: 18.3.1
next-auth: 5.0.0-beta.28
@auth/core: 0.39.1

Reproduction URL

https://github.com/nextauthjs/next-auth-example

Describe the issue

I'm using typebot 3.8.0 which uses auth.js - 5.0.0.beta28.
As IDP a Zitadel Cloud instance is used.

I encounter the problem that a OAuthProfileParseError is thrown for users which do not have a profile picture set.
For users with no profile picture Zitadel does not return the picture-path in the token leading the picture path to be undefined, making auth.js throwing the error. For users having a profile picture set, the path is available and everything works fine. Log:

[auth[][error] OAuthProfileParseError: Read more at https://errors.authjs.dev#oauthprofileparseerror
[auth[][cause]: ZodError: [
  {
    "code": "invalid_type",
    "expected": "string",
    "received": "undefined",
    "path": [
      "image"
    ],
    "message": "Required"
  }
]
    at get error (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:289:200644)
    at ed.parse (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:289:202840)
    at Object.profile (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:787:4159)
    at cG (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:37189)
    at cV (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:37111)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async c4 (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:42455)
    at async la (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:54302)
    at async lr (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:59016)
    at async tf.do (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:18:18835)
[auth[][details]: {
  "provider": "custom-oauth"
}
[auth[][error] InvalidCheck: pkceCodeVerifier value could not be parsed. Read more at https://errors.authjs.dev#invalidcheck
    at cI (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:30999)
    at Object.use (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:31408)
    at cV (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:35255)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async c4 (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:42455)
    at async la (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:54302)
    at async lr (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:59016)
    at async tf.do (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:18:18835)
    at async tf.handle (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:18:23727)
    at async doRender (/app/node_modules/next/dist/server/base-server.js:1513:42)

Not sure if this is a bug or in this package or having the picture-path is a requirement of the OAuth flow and Zitadel or typeboy should fix/handle this?

How to reproduce

PKCE OAuth flow using a JWT not containing picture / image - path should fail the flow.

Expected behavior

User can log in as having a profile picture URL / profile picture set should not be a requirement? (Correct me if I'm wrong).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginvalid reproductionThe issue did not have a detectable valid reproduction URLtriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions