Skip to content

ConvexProviderWithClerk sends raw session tokens instead of JWT template tokens in v1.34.0 #145

@anilmadhub

Description

@anilmadhub

Description

After upgrading from convex@1.32.0 to convex@1.34.0, ConvexProviderWithClerk sends raw Clerk session tokens instead of tokens generated via the "convex" JWT template. This causes ctx.auth.getUserIdentity() on the server to return an identity missing all custom template claims (e.g. role, name, email).

Root cause

In v1.34.0, ConvexProviderWithClerk added a conditional that skips the JWT template when sessionClaims?.aud === "convex":

// v1.34.0 — broken
if (sessionClaims?.aud === "convex") {
  return await getToken({ skipCache: forceRefreshToken }); // no template!
} else {
  return await getToken({ template: "convex", skipCache: forceRefreshToken });
}

When aud === "convex", it calls getToken() without template: "convex", returning the raw session token which lacks custom JWT template claims.

In v1.32.0, it always requested the template:

// v1.32.0 — correct
return await getToken({
  template: "convex",
  skipCache: forceRefreshToken
});

Reproduction

Setup:

  • ConvexProviderWithClerk with useAuth from @clerk/clerk-react
  • Clerk JWT template named "convex" configured with custom claims including role

With convex@1.32.0getUserIdentity() returns the full template token:

{
  "tokenIdentifier": "...",
  "name": "...",
  "email": "...",
}

With convex@1.34.0getUserIdentity() returns a raw session token:

{
  "tokenIdentifier": "...",
  "fva": [74, -1],
  "sid": "sess_...",
  "sts": "active",
  "v": 2
}

Same Clerk project, same Convex deployment, same JWT template — only the convex package version changed.

Impact

Any server-side code that reads custom claims from the identity (e.g. role-based access control via identity.role) breaks silently, since those fields are missing from the raw session token.

Workaround

Pin convex to 1.32.0 in package.json.

Environment

  • convex: 1.34.0 (broken), 1.32.0 (working)
  • @clerk/clerk-react: ^5.x
  • convex/react-clerk: ConvexProviderWithClerk

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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