parse-community / parse-community/parse-server
Errors after setting `enableAnonymousUsers: false`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 21.4k
- Forks
- 4.8k
- Avg merge
- 7h 45m
- Merged PRs (30d)
- 11
Description
New Issue Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
- I can reproduce the issue with the latest version of Parse Server.
Issue Description
I had anonymous users enabled in my server, but after changing enableAnonymousUsers: true to false I get a lot of errors when querying the _User class/list in the Parse dashboard and from Cloud code.
TypeError: Cannot read properties of undefined (reading 'afterFind')
at /home/parse/node_modules/parse-server/lib/Adapters/Auth/index.js:204:11
at Array.map (<anonymous>)
at Object.runAfterFind (/home/parse/node_modules/parse-server/lib/Adapters/Auth/index.js:197:32)
at /home/parse/node_modules/parse-server/lib/RestQuery.js:698:85
at Array.map (<anonymous>)
at RestQuery.handleAuthAdapters (/home/parse/node_modules/parse-server/lib/RestQuery.js:698:43)
at /home/parse/node_modules/parse-server/lib/RestQuery.js:201:17
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
All anonymous users have been deleted from the database but that did not solve the problem.
All other classes load fine but not the _User class.
Steps to reproduce
Add anonymous users when enableAnonymousUsers: true and convert some of them into real users (with an email).
Set enableAnonymousUsers: false and query the _User class.
Actual Outcome
Server error, no results are returned.
Expected Outcome
The query to work.
Environment
Server
- Parse Server version:
6.2.1 - Operating system:
Ubuntu server 20.04 - Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc):
remote VPS
Database
- System (MongoDB or Postgres):
MongoDB - Database version:
4.4.22 - Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc):
remote VPS
Client
- SDK (iOS, Android, JavaScript, PHP, Unity, etc):
Parse dashboard / Cloud code - SDK version:
5.1.0 / 6.2.1
Logs
Crashes at line 235 since adapter is null.
https://github.com/parse-community/parse-server/blob/a742656a90a3db73b5d2087c4643a144637ae6bb/src/Adapters/Auth/index.js#L213-L235
Fixed by
I replaced enableAnonymousUsers: false with
auth: {
anonymous: {
enabled: false
}
}
and it no longer crashes.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/Adapters/Auth/index.js around lines 213-235, then reproduce the issue by creating anonymous users, disabling enableAnonymousUsers, and querying the _User class. Compare the failing configuration with the working auth.anonymous.enabled setting; done means _User queries from the dashboard and Cloud Code return results without a server error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mongodb, node.js
- Domain
- api, authentication, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100