Skip to content

Session token refresh silently fails when user lacks organization access, returning null without error logging #244

@shenst1

Description

@shenst1

Steps to reproduce

Enable organizations in Clerk environment settings
Create a user account before organizations were enabled (user has no organization assigned)
Attempt to refresh session token via clerk.sessionToken() or clerk.sessionToken(organization: org)
Observe the API call to /client/sessions endpoint
Check the response - API returns 404/403 with organization access error
Verify the method behavior - _updateSessionToken() returns null silently

Location: lib/src/clerk_api/api.dart around line 825 in the _updateSessionToken method
Impact: Authentication failures are invisible to developers, making it impossible to diagnose organization-related access issues without manual API inspection.

Pr 243

Expected results

Error should be logged using the library's logging mechanism (logSevere)
Error details should be captured including the specific error code and message
Method should throw an exception or return an ApiResponse.fatal() instead of silently returning null
Developer should be informed about the organization access issue

Actual results

No error logging occurs - the error response is completely swallowed
Method returns null without any indication of what went wrong
API error details are lost including the valuable error code "organization_not_found_or_unauthorized"
Developer has no visibility into why the session token refresh failed
Silent failure makes debugging authentication issues extremely difficult

Code sample

Code sample
{
  "errors": [
    {
      "message": "not found or unauthorized",
      "long_message": "Given organization not found, or you don't have permission to access the organization",
      "code": "organization_not_found_or_unauthorized"
    }
  ]
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingclerk_authpackage: clerk_auth

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions