nextcloud / nextcloud/server

[Bug]: Total user count was negative

Open
#50,955 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage 30-feedback bug feature: ldap feature: users and groups
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

⚠️ This issue respects the following points: ⚠️
Bug description

Nextcloud logs get spammed with this:

Total user count was negative (users: 6, disabled: 12)

I have the following number of users:

  • Database backend:
    • active: 5
    • disabled: 1
  • Guest backend:
    • active: 2
    • disabled: 0
  • LDAP backend:
    • active: 10+
    • disabled: 11

So it seems to count the disabled users correctly: "12".

Not sure how it comes to the conclusion of "6" users though, since it should be "8" (all database + guest if it simply ignorese ldap) or "7" (all active database + guest).

Maybe something with counting the ldap users is wrong?

Steps to reproduce
  1. Connect LDAP server to nextcloud (if ldap is the issue)
  2. Deactivate some database users
Expected behavior

No error message in logs.

Nextcloud Server version

30

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.3

Web server

Nginx

Database engine version

MySQL

Is this bug present after an update or on a fresh install?

None

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report
{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbtableprefix": "oc_",
        "version": "30.0.6.2",
        "installed": true,
        "forcessl": true,
        "maxZipInputSize": 838860800,
        "allowZipDownload": true,
        "theme": "",
        "log_type": "file",
        "loglevel": 2,
        "log_query": false,
        "logdateformat": "Y.m.d H:i:s",
        "logfile": "\/var\/log\/nextcloud\/nextcloud.log",
        "trusted_domains": [
            "**SENSITIVE**"
        ],
        "mail_smtpmode": "smtp",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "default_phone_region": "DE",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "forceSSLforSubdomains": true,
        "filelocking.enabled": true,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "logtimezone": "Europe\/Berlin",
        "ldapIgnoreNamingRules": false,
        "trashbin_retention_obligation": "auto",
        "updatechecker": false,
        "updater.server.url": "***REMOVED SENSITIVE VALUE***",
        "updater.release.channel": "stable",
        "maintenance_window_start": 1,
        "profile.enabled": false,
        "enabledPreviewProviders": [
            "OC\\Preview\\PNG",
            "OC\\Preview\\JPEG",
            "OC\\Preview\\GIF",
            "OC\\Preview\\BMP",
            "OC\\Preview\\XBitmap",
            "OC\\Preview\\MP3",
            "OC\\Preview\\TXT",
            "OC\\Preview\\MarkDown",
            "OC\\Preview\\OpenDocument",
            "OC\\Preview\\Krita",
            "OC\\Preview\\PDF",
            "OC\\Preview\\HEIC",
            "OC\\Preview\\Movie",
            "OC\\Preview\\TIFF",
            "OC\\Preview\\Image"
        ],
        "preview_max_scale_factor": 1,
        "preview_max_memory": 1280,
        "preview_max_x": 1024,
        "preview_max_y": 1024,
        "htaccess.RewriteBase": "\/",
        "ldapProviderFactory": "\\OCA\\User_LDAP\\LDAPProviderFactory",
        "maintenance": false,
        "mail_smtpsecure": "tls",
        "mail_smtpauthtype": "PLAIN",
        "mail_smtpauth": 1,
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "25",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mysql.utf8mb4": true,
        "app_install_overwrite": [
            "ocsms",
            "maps",
            "spreed",
            "tasks",
            "memories"
        ],
        "data-fingerprint": "c3a5ef2e8d8ae76b76546fbd0dfba4c8",
        "overwrite.cli.url": "**SENSITIVE**",
        "twofactor_enforced": "true",
        "twofactor_enforced_groups": [
            "**SENSITIVE**"
        ],
        "twofactor_enforced_excluded_groups": [],
        "memories.exiftool": "\/var\/www\/owncloud\/apps\/memories\/bin-ext\/exiftool-amd64-glibc",
        "memories.vod.path": "\/var\/www\/owncloud\/apps\/memories\/bin-ext\/go-vod-amd64",
        "memories.vod.disable": false,
        "memories.vod.ffmpeg": "\/usr\/bin\/ffmpeg",
        "memories.vod.ffprobe": "\/usr\/bin\/ffprobe",
        "memories.gis_type": 1,
        "memories.db.triggers.fcu": true,
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***"
    }
}
List of activated Apps
Enabled:
  - activity: 3.0.0
  - admin_audit: 1.20.0
  - bruteforcesettings: 3.0.0
  - calendar: 5.1.0
  - call_summary_bot: 2.0.1
  - circles: 30.0.0
  - cloud_federation_api: 1.13.0
  - comments: 1.20.1
  - contacts: 7.0.0
  - contactsinteraction: 1.11.0
  - dashboard: 7.10.0
  - dav: 1.31.1
  - federatedfilesharing: 1.20.0
  - federation: 1.20.0
  - files: 2.2.0
  - files_downloadlimit: 3.0.0
  - files_external: 1.22.0
  - files_pdfviewer: 3.0.0
  - files_reminders: 1.3.0
  - files_sharing: 1.22.0
  - files_trashbin: 1.20.1
  - files_versions: 1.23.0
  - firstrunwizard: 3.0.0
  - guests: 4.1.0
  - impersonate: 1.17.1
  - logreader: 3.0.0
  - lookup_server_connector: 1.18.0
  - maps: 1.5.0
  - memories: 7.4.1
  - nextcloud_announcements: 2.0.0
  - notes: 4.11.0
  - notifications: 3.0.0
  - notify_push: 1.0.0
  - oauth2: 1.18.1
  - password_policy: 2.0.0
  - photos: 3.0.2
  - polls: 7.3.1
  - previewgenerator: 5.8.0
  - privacy: 2.0.0
  - provisioning_api: 1.20.0
  - recognize: 8.2.0
  - recommendations: 3.0.0
  - related_resources: 1.5.0
  - serverinfo: 2.0.0
  - settings: 1.13.0
  - sharebymail: 1.20.0
  - spreed: 20.1.4
  - support: 2.0.0
  - systemtags: 1.20.0
  - tables: 0.8.4
  - tasks: 0.16.1
  - text: 4.1.0
  - theming: 2.6.0
  - twofactor_backupcodes: 1.19.0
  - twofactor_totp: 12.0.0-dev
  - twofactor_webauthn: 2.1.0
  - user_ldap: 1.21.0
  - user_status: 1.10.0
  - viewer: 3.0.0
  - weather_status: 1.10.0
  - webhook_listeners: 1.1.0-dev
  - workflowengine: 2.12.0
Disabled:
  - app_api: 4.0.6 (installed 4.0.6)
  - appointments: 2.3.5 (installed 2.3.5)
  - assistant: 2.3.0 (installed 2.3.0)
  - context_chat: 4.1.0 (installed 4.1.0)
  - deck: 1.14.3 (installed 1.14.3)
  - encryption: 2.18.0 (installed 2.1.0)
  - end_to_end_encryption: 1.16.2 (installed 1.16.2)
  - files_accesscontrol: 1.20.1 (installed 1.20.1)
  - files_automatedtagging: 1.20.0 (installed 1.20.0)
  - files_downloadactivity: 1.17.0 (installed 1.17.0)
  - files_retention: 1.19.0 (installed 1.19.0)
  - files_rightclick: 0.15.1 (installed 1.6.0)
  - forms: 4.3.7 (installed 4.3.7)
  - groupfolders: 18.1.0 (installed 18.1.0)
  - integration_mattermost: 2.1.0 (installed 2.1.0)
  - mail: 4.2.0 (installed 4.2.0)
  - phonetrack: 0.8.2 (installed 0.8.2)
  - survey_client: 2.0.0 (installed 2.0.0)
  - suspicious_login: 8.0.0 (installed 6.0.0)
  - twofactor_admin: 4.7.1 (installed 4.7.1)
  - twofactor_nextcloud_notification: 4.0.0
  - updatenotification: 1.20.0 (installed 1.20.0)
  - whiteboard: 1.0.5 (installed 1.0.5)
Nextcloud Signing status
No errors have been found.
Nextcloud Logs
{"reqId":"MqiHunCA0mrm2EUCaAoq","level":2,"time":"2025.02.21 15:28:06","remoteAddr":"***","user":"***","app":"support","method":"GET","url":"/apps/logreader/api/poll?lastReqId=ESR13Vno2fE4D4QJ9IpV","message":"Total user count was negative (users: 6, disabled: 12)","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:136.0) Gecko/20100101 Firefox/136.0","version":"30.0.6.2","data":{"app":"support"}}
Additional info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the support app code that emits the "Total user count was negative" message, then trace how database, guest, and LDAP backends contribute active and disabled users. Compare the calculation with the reported counts and verify that the configured backends no longer produce an incorrect negative total or log error.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, php
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.