milux / ctldap

LDAP Wrapper for ChurchTools
GNU General Public License v3.0
12 stars 8 forks source link

Churchtools 3.100 sends a HTTP Response code 500 back #43

Closed miltechniks closed 1 year ago

miltechniks commented 1 year ago

With the latest Update of Churchtools today with the Version 3.100 the Wrapper is broken. I had a look to the Logs (Debug enabled) and there I can see that the server sends an HTTP Response Code 500 back. As far, as I understand the JavaScript Code, the request is to /api/persons and /api/groups When I test the requests with Swagger from Churchtools (/api) the request for /api/persons does require really long but return successfully a result. The request to /api/groups returns an error back. Is there anyone else with this problem?

I used the latest Version of the Wrapper.

And here are the logs (redacted):

2023-07-10T09:09:00.305Z [DEBUG] root logger - Debug mode enabled, expect lots of output!
2023-07-10T09:09:00.309Z [DEBUG] root logger - ChurchTools-LDAP-Wrapper listening @ ldap://0.0.0.0:1389
2023-07-10T09:09:11.788Z [DEBUG] ORGANISATION - Admin bind DN: cn=root, ou=users, o=ORGANISATION
2023-07-10T09:09:11.788Z [DEBUG] ORGANISATION - Admin bind successful
2023-07-10T09:09:11.791Z [DEBUG] undefined - Empty request, return directory information
2023-07-10T09:09:11.838Z [DEBUG] ORGANISATION - SEARCH base object: o=ORGANISATION scope: sub
2023-07-10T09:09:11.838Z [DEBUG] ORGANISATION - Filter: (&(cn=USERNAME)(objectclass=ctperson)(memberof=cn=GROUP,ou=groups,o=ORGANISATION))
2023-07-10T09:09:11.838Z [DEBUG] ORGANISATION - Search for users and groups combined
2023-07-10T09:09:11.842Z [DEBUG] ORGANISATION - Wait on Promise for cache key "rawData".
2023-07-10T09:09:11.842Z [DEBUG] ORGANISATION - Wait on Promise for cache key "users".
2023-07-10T09:09:11.842Z [DEBUG] ORGANISATION - Returning pending Promise for cache key "rawData".
2023-07-10T09:09:11.842Z [DEBUG] ORGANISATION - Wait on Promise for cache key "rawData".
2023-07-10T09:09:11.842Z [DEBUG] ORGANISATION - Wait on Promise for cache key "groups".
2023-07-10T09:09:12.358Z [DEBUG] ORGANISATION - fetchGroupTypes done
2023-07-10T09:09:12.472Z [DEBUG] ORGANISATION - fetchMemberships done
2023-07-10T09:09:13.515Z [DEBUG] ORGANISATION - fetchPersons done
2023-07-10T09:09:15.758Z [ERROR] ORGANISATION - Error while retrieving users: 
HTTPError: Response code 500 (Internal Server Error)
    at Request.<anonymous> (file:///app/node_modules/got/dist/source/as-promise/index.js:86:42)
    at Object.onceWrapper (node:events:628:26)
    at Request.emit (node:events:525:35)
    at Request._onResponseBase (file:///app/node_modules/got/dist/source/core/index.js:726:22)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Request._onResponse (file:///app/node_modules/got/dist/source/core/index.js:765:13)
2023-07-10T09:09:15.758Z [ERROR] ORGANISATION - Error while retrieving groups: 
HTTPError: Response code 500 (Internal Server Error)
    at Request.<anonymous> (file:///app/node_modules/got/dist/source/as-promise/index.js:86:42)
    at Object.onceWrapper (node:events:628:26)
    at Request.emit (node:events:525:35)
    at Request._onResponseBase (file:///app/node_modules/got/dist/source/core/index.js:726:22)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Request._onResponse (file:///app/node_modules/got/dist/source/core/index.js:765:13)
ThreeDPara commented 1 year ago

Same here. The /groups request with limit -1 returns the 500 error response:

An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-1' at line 1

milux commented 1 year ago

I confirm this behavior. CT devs made an improvement of their API which broke my hackish approach for efficient pagination bypassing. :(

Due to our status as self-hosters, I was able to patch ChurchTools directly. If you are self-hosters, you can do the same in the source code. WARNING: This is officially violating CT EULA, although CT devs will probably tolerate it for the sake of customer satisfaction!

In system/src/Api/ApiPaginator.php, Zeile 31, replace $this->limit = $limit; by $this->limit = $limit < 1 ? PHP_INT_MAX : $limit;

This will fix it temporarily, while I'm working on a fixed ctldap version using the old API calls because of @djschilling's advice, see here for our discussion: https://forum.church.tools/topic/9606/version-3-100-0/8

milux commented 1 year ago

See also #44 for a temporary solution, which is however very slow for very large amounts of users.

milux commented 1 year ago

Fixed in 3.0.2, therefore closing. Limits are currently hardcoded for ChurchTools 3.0.100 and higher!