Cronjob fails with TypeError

Nextcloud version (eg, 20.0.5): 23.0.4
Operating system and version (eg, Ubuntu 20.04): Debian bullseye
Apache or nginx version (eg, Apache 2.4.25): 2.4.53-2
PHP version (eg, 7.4): 7.4

The issue you are facing:
When I run the php cron job I get the following error:

TypeError: substr() expects parameter 1 to be string, bool given in /srv/node3.web.nextcloud.XXX.XX/nextcloud/lib/private/Security/Crypto.php:98
Stack trace:
#0 /srv/node3.web.nextcloud.bfh.science/nextcloud/lib/private/Security/Crypto.php(98): substr()
#1 /srv/node3.web.nextcloud.XXX.XX/nextcloud/lib/private/Security/IdentityProof/Manager.php(111): OC\
Security\Crypto->encrypt()
#2 /srv/node3.web.nextcloud.XXX.XX/nextcloud/lib/private/Security/IdentityProof/Manager.php(134): OC\
Security\IdentityProof\Manager->generateKey()
#3 /srv/node3.web.nextcloud.bfh.science/nextcloud/lib/private/Security/IdentityProof/Manager.php(147): OC\
Security\IdentityProof\Manager->retrieveKey()
#4 /srv/node3.web.nextcloud.XXX.XX/nextcloud/lib/private/Security/IdentityProof/Signer.php(64): OC\Se
curity\IdentityProof\Manager->getKey()
#5 /srv/node3.web.nextcloud.XXX.XX/nextcloud/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob
.php(150): OC\Security\IdentityProof\Signer->sign()
#6 /srv/node3.web.nextcloud.XXX.XX/nextcloud/lib/public/BackgroundJob/Job.php(79): OCA\LookupServerCo
nnector\BackgroundJobs\RetryJob->run()
#7 /srv/node3.web.nextcloud.bfh.science/nextcloud/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob
.php(113): OCP\BackgroundJob\Job->execute()
#8 /srv/node3.web.nextcloud.XXX.XX/nextcloud/cron.php(150): OCA\LookupServerConnector\BackgroundJobs\
RetryJob->execute()
#9 {main}

Is this the first time you’ve seen this error? (Y/N): N

Steps to replicate it:

  1. Log into your nextcloud web server
  2. Execute
    sudo -u www-data /usr/bin/php <your-nextcloud-home>/nextcloud/cron.php

The output of your Nextcloud log in Admin > Logging:

Error	cron	TypeError: substr() expects parameter 1 to be string, bool given

    /srv/node2.web.nextcloud.XXX.XX/nextcloud/lib/private/Security/Crypto.php - line 98:

    substr()

    /srv/node2.web.nextcloud.bfh.science/nextcloud/lib/private/Security/IdentityProof/Manager.php - line 111:

    OC\Security\Crypto->encrypt("*** sensiti ... *")

    /srv/node2.web.nextcloud.XXX.XX/nextcloud/lib/private/Security/IdentityProof/Manager.php - line 134:

    OC\Security\IdentityProof\Manager->generateKey()

    /srv/node2.web.nextcloud.XXX.XX/nextcloud/lib/private/Security/IdentityProof/Manager.php - line 147:

    OC\Security\IdentityProof\Manager->retrieveKey()

    /srv/node2.web.nextcloud.XXX.XX/nextcloud/lib/private/Security/IdentityProof/Signer.php - line 64:

    OC\Security\IdentityProof\Manager->getKey()

    /srv/node2.web.nextcloud.XXX.XX/nextcloud/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php - line 150:

    OC\Security\IdentityProof\Signer->sign()

    /srv/node2.web.nextcloud.XXX.XX/nextcloud/lib/public/BackgroundJob/Job.php - line 79:

    OCA\LookupServerConnector\BackgroundJobs\RetryJob->run()

    /srv/node2.web.nextcloud.XXX.XX/nextcloud/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php - line 113:

    OCP\BackgroundJob\Job->execute()

    /srv/node2.web.nextcloud.bfh.science/nextcloud/cron.php - line 150:

    OCA\LookupServerConnector\BackgroundJobs\RetryJob->execute()

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

{
    "system": {
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "node3.web.nextcloud.XXX.XX",
            "nextcloud.XXX.XX"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "23.0.4.1",
        "overwrite.cli.url": "https:\/\/nextcloud.XXX.XX",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "overwrite.host": "nextcloud.XXX.XX",
        "overwriteprotocol": "https",
        "memcache.local": "\\OC\\Memcache\\Memcached",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": "6379",
            "password": "***REMOVED SENSITIVE VALUE***"
        },
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "updater.release.channel": "stable",
        "trashbin_retention_obligation": "92",
        "defaultapp": "files",
        "logtimezone": "Europe\/Zurich",
        "log_rotate_size": "1073741824",
        "default_phone_region": "CH",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "skeletondirectory": "\/srv\/node3.web.nextcloud.XXX.XX\/nextcloud\/skeleton-bfh",
        "theme": "",
        "lost_password_link": "disabled",
        "loglevel": 2,
        "maintenance": false
    },
    "apps": {
        "accessibility": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.9.0"
        },
        "activity": {
            "types": "filesystem",
            "enabled": "yes",
            "installed_version": "2.15.0",
            "notify_notification_security": "1",
            "notify_notification_personal_settings": "0",
            "notify_notification_favorite": "0",
            "notify_email_favorite": "0",
            "notify_notification_file_changed": "0",
            "notify_email_file_changed": "0",
            "notify_notification_file_favorite_changed": "1",
            "notify_email_file_favorite_changed": "0",
            "notify_notification_comments": "0",
            "notify_email_comments": "0",
            "notify_notification_calendar": "0",
            "notify_email_calendar": "0",
            "notify_notification_calendar_event": "0",
            "notify_email_calendar_event": "0",
            "notify_notification_calendar_todo": "0",
            "notify_email_calendar_todo": "0",
            "notify_notification_shared": "0",
            "notify_email_shared": "0",
            "notify_notification_remote_share": "0",
            "notify_email_remote_share": "0",
            "notify_notification_public_links": "0",
            "notify_email_public_links": "0",
            "notify_notification_systemtags": "0",
            "notify_email_systemtags": "0",
            "notify_setting_batchtime": "3600",
            "notify_setting_self": "0",
            "notify_setting_selfemail": "0",
            "notify_notification_group_settings": "0"
        },
        "admin_audit": {
            "installed_version": "1.13.0",
            "types": "logging",
            "enabled": "yes"
        },
        "backgroundjob": {
            "lastjob": "993020"
        },
        "bruteforcesettings": {
            "types": "",
            "installed_version": "2.4.0",
            "enabled": "yes"
        },
        "circles": {
            "enabled": "no",
            "installed_version": "22.1.1",
            "types": "filesystem,dav",
            "loopback_tmp_scheme": "https"
        },
        "cloud_federation_api": {
            "types": "filesystem",
            "enabled": "yes",
            "installed_version": "1.6.0"
        },
        "comments": {
            "types": "logging",
            "enabled": "yes",
            "installed_version": "1.13.0"
        },
        "contacts": {
            "enabled": "yes",
            "types": "dav",
            "installed_version": "4.1.0"
        },
        "contactsinteraction": {
            "types": "dav",
            "enabled": "yes",
            "installed_version": "1.4.0"
        },
        "core": {
            "vendor": "nextcloud",
            "public_webdav": "dav\/appinfo\/v1\/publicwebdav.php",
            "public_files": "files_sharing\/public.php",
            "moveavatarsdone": "yes",
            "previewsCleanedUp": "1",
            "backgroundjobs_mode": "cron",
            "installed.bundles": "[\"CoreBundle\"]",
            "lastupdateResult": "[]",
            "installedat": "1622577491.5242",
            "lastupdatedat": "0",
            "theming.variables": "6f4ef1240090ef23eef18cef9374d344",
            "lastcron": "1651514465",
            "oc.integritycheck.checker": "{\"core\":{\"FILE_MISSING\":{\"3rdparty\\\/.github\\\/dependabot.yml\":{\"expected\":\"8e4b15c88041ddc2d51190bc1cb35d633762a673b22862779f5902fdc792fdc355c20d5becaa14531759c384642bb39108d8e5ec3fff1481a78e3a4e4d4f72dc\",\"current\":\"\"},\"3rdparty\\\/.github\\\/workflows\\\/block-merge-freeze.yml\":{\"expected\":\"f914cc15f206a4aa32aaa8efa5d0b74138d243ae342fb1d4ee1a8748099bf9229efcca1aef2d7351fcbf0505049904f3016edac896b08987bab24d356f7f2280\",\"current\":\"\"},\"3rdparty\\\/aws\\\/aws-sdk-php\\\/src\\\/data\\\/accessanalyzer\\\/2019-11-01\\\/api-2.json.php\":{\"expected\":\"bb7737a58c7e1e0d330eb3f124110230ba96db7fe8b8afddde014df0d567c2a20a08883132936acf7a9e15da3758cacedcfc4a833dccb71d08081a079eb05ffe\",\"current\":\"\"},\"3rdparty\\\/aws\\\/aws-sdk-php\\\/src\\\/data\\\/accessanalyzer\\\/2019-11-01\\\/paginators-1.json.php\":{\"expected\":\"78c7c7bde58b4b52f9ae5569f5ac296992f62bba7150a6df7f8ef6335b01102f2fd89997c1c6bccc537838f9b14909bc85a3f26e8cf5ff6cb0b8adafd83ee89a.....
        },
        "dashboard": {
            "installed_version": "7.3.0",
            "types": "",
            "enabled": "yes"
        },
        "dav": {
            "types": "filesystem",
            "enabled": "yes",
            "chunks_migrated": "1",
            "installed_version": "1.21.0",
            "regeneratedBirthdayCalendarsForYearFix": "yes",
            "buildCalendarSearchIndex": "yes",
            "buildCalendarReminderIndex": "yes"
        },
        "federatedfilesharing": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.13.0"
        },
        "federation": {
            "installed_version": "1.13.0",
            "types": "authentication",
            "enabled": "yes"
        },
        "files": {
            "types": "filesystem",
            "enabled": "yes",
            "installed_version": "1.18.0",
            "cronjob_scan_files": "8500"
        },
        "files_pdfviewer": {
            "types": "",
            "enabled": "yes",
            "installed_version": "2.4.0"
        },
        "files_rightclick": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.2.0"
        },
        "files_sharing": {
            "types": "filesystem",
            "enabled": "yes",
            "installed_version": "1.15.0"
        },
        "files_trashbin": {
            "types": "filesystem,dav",
            "enabled": "yes",
            "installed_version": "1.13.0"
        },
        "files_versions": {
            "types": "filesystem,dav",
            "enabled": "yes",
            "installed_version": "1.16.0"
        },
        "files_videoplayer": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.12.0"
        },
        "firstrunwizard": {
            "types": "logging",
            "enabled": "yes",
            "installed_version": "2.12.0"
        },
        "groupfolders": {
            "types": "filesystem,dav",
            "enabled": "no",
            "installed_version": "11.1.2"
        },
        "logreader": {
            "types": "",
            "enabled": "yes",
            "installed_version": "2.8.0"
        },
        "lookup_server_connector": {
            "types": "authentication",
            "enabled": "yes",
            "installed_version": "1.11.0"
        },
        "nextcloud_announcements": {
            "types": "logging",
            "enabled": "yes",
            "installed_version": "1.12.0",
            "pub_date": "Thu, 24 Oct 2019 00:00:00 +0200"
        },
        "notifications": {
            "types": "logging",
            "enabled": "yes",
            "installed_version": "2.11.1"
        },
        "oauth2": {
            "installed_version": "1.11.0",
            "types": "authentication",
            "enabled": "yes"
        },
        "password_policy": {
            "enabled": "yes",
            "types": "authentication",
            "installed_version": "1.13.0"
        },
        "photos": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.5.0"
        },
        "previewgenerator": {
            "installed_version": "4.0.0",
            "types": "filesystem",
            "enabled": "yes"
        },
        "privacy": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.7.0"
        },
        "provisioning_api": {
            "types": "prevent_group_restriction",
            "enabled": "yes",
            "installed_version": "1.13.0"
        },
        "recommendations": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.2.0"
        },
        "serverinfo": {
            "types": "",
            "enabled": "yes",
            "cached_count_filecache": "13472611",
            "cached_count_storages": "23408",
            "installed_version": "1.13.0"
        },
        "settings": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.5.0"
        },
        "sharebymail": {
            "installed_version": "1.13.0",
            "types": "filesystem",
            "enabled": "yes"
        },
        "support": {
            "types": "session",
            "enabled": "yes",
            "installed_version": "1.6.0",
            "SwitchUpdaterServerHasRun": "yes",
            "last_notification": "1649692889"
        },
        "survey_client": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.11.0"
        },
        "systemtags": {
            "types": "logging",
            "enabled": "yes",
            "installed_version": "1.13.0"
        },
        "text": {
            "types": "dav",
            "enabled": "yes",
            "installed_version": "3.4.1"
        },
        "theming": {
            "types": "logging",
            "enabled": "yes",
            "color": "#697d91",
            "logoMime": "image\/svg+xml",
            "installed_version": "1.14.0"
        },
        "twofactor_backupcodes": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.12.0"
        },
        "updatenotification": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.13.0",
            "contacts": "4.1.0",
            "previewgenerator": "3.1.1",
            "bruteforcesettings": "2.4.0",
            "update_check_errors": "0",
            "core": "23.0.4.1",
            "groupfolders": "9.0.3"
        },
        "user_ldap": {
            "s01ldap_matching_rule_in_chain_state": "unavailable",
            "installed_version": "1.13.1",
            "types": "authentication",
            "enabled": "yes",
            "s01_lastChange": "1640820489",
            "s01ldap_backup_port": "636",
            "s01ldap_base_users": "ou=Accounts,dc=bfh",
            "s01ldap_expert_uuid_user_attr": "bfhOid",
            "s01ldap_group_display_name": "cn",
            "s01ldap_group_member_assoc_attribute": "member",
            "s01ldap_loginfilter_username": "1",
            "s01ldap_display_name": "displayName",
            "background_sync_prefix": "s01",
            "background_sync_interval": "1800",
            "s01ldap_configuration_active": "1",
            "s01has_memberof_filter_support": "1",
            "s01ldap_base": "dc=XXX",
            "s01ldap_email_attr": "mail",
            "s01ldap_expert_username_attr": "cn",
            "s01ldap_group_filter": "(&(|(objectclass=bfhGroup)))",
            "s01ldap_host": "ldaps:\/\/node1.ldap.XXX.XX",
            "s01ldap_nested_groups": "1",
            "s01ldap_user_display_name_2": "cn",
            "cleanUpJobOffset": "21500",
            "background_sync_offset": "1000",
            "s01ldap_backup_host": "ldaps:\/\/node2.ldap.XXX.XX",
            "s01ldap_base_groups": "ou=Security,ou=Groups,dc=XXX",
            "s01ldap_expert_uuid_group_attr": "bfhOid",
            "s01ldap_gid_number": "gidNumber",
            "s01ldap_groupfilter_objectclass": "bfhGroup",
            "s01ldap_login_filter": "(&(objectClass=bfhAccount)(|(&(ou:dn:=Staff)(ou:dn:=Accounts))(&(ou:dn:=Students)(ou:dn:=Accounts))(memberOf=cn=idm.lfe.nextcloud.users-manual,ou=security,ou=groups,dc=XXX))(uid=%uid))",
            "s01ldap_port": "636",
            "s01ldap_userlist_filter": "(&(objectClass=bfhAccount)(|(&(ou:dn:=Staff)(ou:dn:=Accounts))(&(ou:dn:=Students)(ou:dn:=Accounts))(memberOf=cn=idm.lfe.nextcloud.users-manual,ou=security,ou=groups,dc=XXX)))"
        },
        "user_status": {
            "installed_version": "1.3.1",
            "types": "",
            "enabled": "yes"
        },
        "viewer": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.7.0"
        },
        "weather_status": {
            "installed_version": "1.3.0",
            "types": "",
            "enabled": "yes"
        },
        "workflowengine": {
            "types": "filesystem",
            "enabled": "yes",
            "installed_version": "2.5.0"
        }
    }
}

The output of your Apache/nginx/system log in /var/log/____:

(...)
<IP> - - [06/May/2022:09:35:48 +0200] "PROPFIND /remote.php/dav/files/XXX15/ HTTP/1.1" 207 1832 "-" "Mozilla/5.0 (Windows) mirall/3.4.4stable-Win64 (build 20220318) (Nextcloud, windows-10.0.19042 ClientArchitecture: x86_64 OsArchitecture: x86_64)" "via HA-Proxy" 147.87.5.46
212.247.254.22 - - [06/May/2022:09:35:53 +0200] "PROPFIND /remote.php/dav/files/XXX3/ HTTP/1.1" 207 1847 "-" "Mozilla/5.0 (Windows) mirall/3.4.4stable-Win64 (build 20220318) (Nextcloud, windows-10.0.19044 ClientArchitecture: x86_64 OsArchitecture: x86_64)" "via HA-Proxy" <IP>
<IP> - - [06/May/2022:09:35:55 +0200] "PROPFIND /remote.php/dav/files/XXX1/ HTTP/1.1" 207 1846 "-" "Mozilla/5.0 (Macintosh) mirall/3.4.2git (build 9042) (Nextcloud, osx-20.6.0 ClientArchitecture: x86_64 OsArchitecture: x86_64)" "via HA-Proxy" <IP>
<IP> - - [06/May/2022:09:35:56 +0200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 6478 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36" "via HA-Proxy" <IP>
<IP> - - [06/May/2022:09:36:00 +0200] "PROPFIND /remote.php/dav/files/rXXX2/ HTTP/1.1" 207 1846 "-" "Mozilla/5.0 (Windows) mirall/3.4.4stable-Win64 (build 20220318) (Nextcloud, windows-10.0.19043 ClientArchitecture: x86_64 OsArchitecture: x86_64)" "via HA-Proxy" <IP>
(...)

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

(none)

Looks like the password hashing function. Not sure why this is needed in the cronjob…

You are using LDAP? The normal webinterface login is working, without this error?

Is this new, or just after an update? When did it work the last time?

Yes, we are using LDAP. The webinterface works without problems.
I think the cron worked the last time under 22.X.X or 23.0.1.

I didn’t find anything related to your error. NC23 is not that new, so I’d guess there is something strange that triggers that issue. However, I have no ideas how to proceed. Probably a bug report is the best. The developers can hopefully pin-point you to the part that is creating the problem.