Skip to content

Conversation

@AlessioGr
Copy link
Member

Previously, the following error may be thrown when no user is present on the req:

 TypeError: Cannot read properties of null (reading 'collection')
    at renderListHandler (packages/next/src/views/List/handleServerFunction.tsx:66:28)
    at async Server.<anonymous> (test/dev.ts:129:5)
  64 |           {
  65 |             'user.relationTo': {
> 66 |               equals: user.collection,
     |                            ^
  67 |             },
  68 |           },
  69 |           { {
  digest: '4059983158'
}
 POST /admin/collections/with-list-drawer 500 in 164ms (compile: 2ms, render: 162ms)

I'm seeing it thrown a lot in our test suites, likely because it's logging out the user while a previous request is still going on.

This PR explicitly throws an UnauthorizedError before the server function tries to access properties on the user object.

@github-actions
Copy link
Contributor

📦 esbuild Bundle Analysis for payload

This analysis was generated by esbuild-bundle-analyzer. 🤖
This PR introduced no changes to the esbuild bundle! 🙌

@AlessioGr AlessioGr merged commit 10a8f0f into main Dec 10, 2025
99 checks passed
@AlessioGr AlessioGr deleted the fix/user-undefined branch December 10, 2025 17:07
@github-actions
Copy link
Contributor

🚀 This is included in version v3.68.2

zubricks pushed a commit that referenced this pull request Jan 6, 2026
…user present (#14878)

Previously, the following error may be thrown when no `user` is present
on the `req`:

```ts
 TypeError: Cannot read properties of null (reading 'collection')
    at renderListHandler (packages/next/src/views/List/handleServerFunction.tsx:66:28)
    at async Server.<anonymous> (test/dev.ts:129:5)
  64 |           {
  65 |             'user.relationTo': {
> 66 |               equals: user.collection,
     |                            ^
  67 |             },
  68 |           },
  69 |           { {
  digest: '4059983158'
}
 POST /admin/collections/with-list-drawer 500 in 164ms (compile: 2ms, render: 162ms)
```

I'm seeing it thrown a lot in our test suites, likely because it's
logging out the user while a previous request is still going on.

This PR explicitly throws an `UnauthorizedError` before the server
function tries to access properties on the `user` object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants