🐛 Bug Report: LDAP Error #141

Closed
opened 2025-10-07 00:03:22 +03:00 by OVERLORD · 9 comments
Owner

Originally created by @drag0n141 on GitHub.

Reproduction steps

Every time the Sync runs i get that error and no users or groups are sync.

That are my LDAP Settings.
Image

Expected behavior

I expect that my Pocket-ID Instance sync my ldap users and groups.

Actual Behavior

Users and Groups get not synced to my Pocket-ID

Version and Environment

v1.5.0 with and ldap connection to my active directory.

Log Output

2025/07/03 09:06:02 github.com/pocket-id/pocket-id/backend/internal/service/ldap_service.go:304 ERROR: invalid byte sequence for encoding "UTF8": 0xb0 (SQLSTATE 22021)
[1.065ms] [rows:0] SELECT * FROM "users" WHERE ldap_id = $1$ ORDER BY "users"."id" LIMIT $2$
[GIN] 2025/07/03 - 09:06:02 | 500 |   35.152815ms |  192.168.140.42 | POST     "/api/application-configuration/sync-ldap"
Error #01: failed to sync users: failed to query for LDAP user ID 'T▒H▒
U▒|': ERROR: invalid byte sequence for encoding "UTF8": 0xb0 (SQLSTATE 22021)
Originally created by @drag0n141 on GitHub. ### Reproduction steps Every time the Sync runs i get that error and no users or groups are sync. That are my LDAP Settings. ![Image](https://github.com/user-attachments/assets/6abb8eca-1384-4b76-8828-cdf4039e49a8) ### Expected behavior I expect that my Pocket-ID Instance sync my ldap users and groups. ### Actual Behavior Users and Groups get not synced to my Pocket-ID ### Version and Environment v1.5.0 with and ldap connection to my active directory. ### Log Output ``` 2025/07/03 09:06:02 github.com/pocket-id/pocket-id/backend/internal/service/ldap_service.go:304 ERROR: invalid byte sequence for encoding "UTF8": 0xb0 (SQLSTATE 22021) [1.065ms] [rows:0] SELECT * FROM "users" WHERE ldap_id = $1$ ORDER BY "users"."id" LIMIT $2$ [GIN] 2025/07/03 - 09:06:02 | 500 | 35.152815ms | 192.168.140.42 | POST "/api/application-configuration/sync-ldap" Error #01: failed to sync users: failed to query for LDAP user ID 'T▒H▒ U▒|': ERROR: invalid byte sequence for encoding "UTF8": 0xb0 (SQLSTATE 22021) ```
OVERLORD added the bug label 2025-10-07 00:03:22 +03:00
Author
Owner

@drag0n141 commented on GitHub:

I think the problem is that objectGUID is an binary

EDIT: I am using the Settings from this issue, https://github.com/pocket-id/pocket-id/issues/553

Dont know why i am have the problem, probably because i am using postgresql and not the sqlite?

What i online found is the postgresql wants to save it as TEXT when its not a valid UTF-8-Text it give this error. With SQLite it does change it variable to BLOB.

@drag0n141 commented on GitHub: I think the problem is that objectGUID is an binary EDIT: I am using the Settings from this issue, https://github.com/pocket-id/pocket-id/issues/553 Dont know why i am have the problem, probably because i am using postgresql and not the sqlite? What i online found is the postgresql wants to save it as `TEXT` when its not a valid UTF-8-Text it give this error. With SQLite it does change it variable to `BLOB`.
Author
Owner

@drag0n141 commented on GitHub:

  • I am using an Active Directory with Windows Server 2025
  • Thats an objectGUID

Image

  • Yes does work without any problem in authelia and authentik
@drag0n141 commented on GitHub: - I am using an Active Directory with Windows Server 2025 - Thats an objectGUID ![Image](https://github.com/user-attachments/assets/952d23ff-665a-4db7-8fbf-4b14b7f9ce12) - Yes does work without any problem in authelia and authentik
Author
Owner

@stonith404 commented on GitHub:

Could you test the ghcr.io/pocket-id/pocket-id:dev-ldap-utf8 image and let me know if this fixes the issue for you?

If it does, please also share the value of ldap_id in the users table.

@stonith404 commented on GitHub: Could you test the `ghcr.io/pocket-id/pocket-id:dev-ldap-utf8` image and let me know if this fixes the issue for you? If it does, please also share the value of `ldap_id` in the `users` table.
Author
Owner

@stonith404 commented on GitHub:

@drag0n141 Thanks! Yes, that's the issue. I think the best solution would be to convert the binary GUID to a string before we save it to the DB.

@stonith404 commented on GitHub: @drag0n141 Thanks! Yes, that's the issue. I think the best solution would be to convert the binary GUID to a string before we save it to the DB.
Author
Owner

@stonith404 commented on GitHub:

Please share some more information:

  • Which LDAP service and version are you using?
  • Can you share an example of an objectGUID?
  • Does the LDAP integration work with other services than Pocket ID?
@stonith404 commented on GitHub: Please share some more information: - Which LDAP service and version are you using? - Can you share an example of an `objectGUID`? - Does the LDAP integration work with other services than Pocket ID?
Author
Owner

@stonith404 commented on GitHub:

Thanks for testing it. Could you pull the image again and retry it?

@stonith404 commented on GitHub: Thanks for testing it. Could you pull the image again and retry it?
Author
Owner

@drag0n141 commented on GitHub:

Now i got the error for the groups

2025/07/03 11:28:12 github.com/pocket-id/pocket-id/backend/internal/service/user_group_service.go:114 ERROR: invalid byte sequence for encoding "UTF8": 0xd7 0xd1 (SQLSTATE 22021)
[1.837ms] [rows:0] INSERT INTO "user_groups" ("id","created_at","friendly_name","name","ldap_id") VALUES ($1$,$2$,$3$,$4$,$5$)
2025/07/03 11:28:12 ERROR Job failed with error name=SyncLdap id=ca89d8b5-5a68-4028-a379-916529c32a50 error="failed to sync groups: failed to create group 'ID-Admin': ERROR: invalid byte sequence for encoding \"UTF8\": 0xd7 0xd1 (SQLSTATE 22021)"
@drag0n141 commented on GitHub: Now i got the error for the groups ``` 2025/07/03 11:28:12 github.com/pocket-id/pocket-id/backend/internal/service/user_group_service.go:114 ERROR: invalid byte sequence for encoding "UTF8": 0xd7 0xd1 (SQLSTATE 22021) [1.837ms] [rows:0] INSERT INTO "user_groups" ("id","created_at","friendly_name","name","ldap_id") VALUES ($1$,$2$,$3$,$4$,$5$) 2025/07/03 11:28:12 ERROR Job failed with error name=SyncLdap id=ca89d8b5-5a68-4028-a379-916529c32a50 error="failed to sync groups: failed to create group 'ID-Admin': ERROR: invalid byte sequence for encoding \"UTF8\": 0xd7 0xd1 (SQLSTATE 22021)" ```
Author
Owner

@drag0n141 commented on GitHub:

It does work now, the users and groups are imported.

The ldap_id of one user b07f1c06-54d3-1848-bd0c-558df97f047c

EDIT: Looks like the Problem is my Browser. It does work now.

@drag0n141 commented on GitHub: It does work now, the users and groups are imported. The ldap_id of one user `b07f1c06-54d3-1848-bd0c-558df97f047c` EDIT: Looks like the Problem is my Browser. It does work now.
Author
Owner

@stonith404 commented on GitHub:

Thanks, the fix should be available in the next release.

@stonith404 commented on GitHub: Thanks, the fix should be available in the next release.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pocket-id#141