Closed paralika closed 3 weeks ago
Any comments here please?
@paralika This looks like an invalid group definition. Is the mainstream-engineering-admin
group something that you created, or is it imported by the plugin?
Can you share what this group looks like? Find this group in Catalog, lick on 3 dots in top right corner, and select inspect entity, there you can find Raw Yaml.
@kadel "mainstream-engineering-admin" is available in Keycloak. The plugin is trying to import it, but it is not successful yet. I have ~1k groups in Keycloak. Out of that, only 341 groups were imported successfully and for others it is failing with this error.
The error message complains about a third member of that group. Can you check the members of that group? Maybe you notice something suspicious. For example, isn't there a user with numeric username?
@kadel I do not see any suspicious chars. Please see the screenshot below. The username is an alphanumeric value pointing to the users.
The Keycloak admin API returns usernames as strings (https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/src/defs/userRepresentation.ts#L10), so I don't think that should be an issue.
I tested by assigning both numeric and alphanumeric usernames to a group, and the sync process worked as expected for users and groups. Here is what I received under spec.members:
spec:
members:
- "078687777"
- z007abc7666666
Are you using any custom transformers in your setup? If so, it's possible that they might be mutating the entity in a way that’s causing type issues during validation.
No, I do not have any custom transformer set. I am following the instructions given at - https://janus-idp.io/plugins/keycloak/
Did you follow the same instructions? Wondering if I missed anything.
I figured out 2 problems:
The groups.members hat entries wich are not in parsedUsers https://github.com/janus-idp/backstage-plugins/blob/58d2baa1073428a77e5c723c8bad1c24e83fd440/plugins/keycloak-backend/src/lib/read.ts#L300
Members are missing when a group has many members (> options?.userQuerySize) https://github.com/janus-idp/backstage-plugins/blob/58d2baa1073428a77e5c723c8bad1c24e83fd440/plugins/keycloak-backend/src/lib/read.ts#L229
- The groups.members hat entries wich are not in parsedUsers https://github.com/janus-idp/backstage-plugins/blob/58d2baa1073428a77e5c723c8bad1c24e83fd440/plugins/keycloak-backend/src/lib/read.ts#L300
@JohannesWill Good catch, I agree with that. The current code could add an undefined value to the group entity member list. Then the plugin will attempt to commit this group to the catalog backend and fail with a TypeError during member list validation. I believe that with a very large database, the Keycloak plugin fetches users using pagination. However, one or more user fetch requests could fail. The current code skips this error and doesn't log it. As a result, the parsed user list will be incomplete, and the group member list could contain undefined values for some users.
- Members are missing when a group has many members (> options?.userQuerySize) https://github.com/janus-idp/backstage-plugins/blob/58d2baa1073428a77e5c723c8bad1c24e83fd440/plugins/keycloak-backend/src/lib/read.ts#L229
Good catch too, but I think we need to fix it like separated issue.
Members are missing when a group has many members (> options?.userQuerySize)
@JohannesWill, thanks. I created issue: https://issues.redhat.com/browse/RHIDP-4391 . Fix is in the road: https://github.com/janus-idp/backstage-plugins/pull/2324
@JohannesWill Good catch, I agree with that. The current code could add an undefined value to the group entity member list. Then the plugin will attempt to commit this group to the catalog backend and fail with a TypeError during member list validation. I believe that with a very large database, the Keycloak plugin fetches users using pagination. However, one or more user fetch requests could fail. The current code skips this error and doesn't log it. As a result, the parsed user list will be incomplete, and the group member list could contain undefined values for some users.
In our case, we have 8 users (service-account-*), which are not included in 'parsedUsers'
In our case, we have 8 users (service-account-*), which are not included in 'parsedUsers'
Oh, make sense, I even didn't know about this Keycloak feature...
Fixed with https://github.com/janus-idp/backstage-plugins/pull/2319 Tested it with "@janus-idp/backstage-plugin-keycloak-backend": "2.0.8"
Thanks @JohannesWill and @AndrienkoAleksandr. It's working.
Apparently fixed in 1.3.1 with update to "@janus-idp/backstage-plugin-keycloak-backend": "1.13.4" in https://github.com/janus-idp/backstage-showcase/pull/1823/files
Related update in 1.3 branch of plugins is https://github.com/janus-idp/backstage-plugins/pull/2429/files#diff-9a8714e6876ad3175b960df6dbacd41b4c818c4dee1617fef0d9e5202e847928R2 ... which is a MAJOR bump, not a patch one?
Ah but then fixed with https://github.com/janus-idp/backstage-plugins/commit/b3835da8bc84edc762e36b81857296fca085b109 to move to 1.13.4
So... I think we're good here! for both 1.3.z and 1.4.
Describe the bug
I have setup the Keycloak backend plugin by following the steps given on below this link - https://janus-idp.io/plugins/keycloak/ . Plugin configure successfully and it started syncing users and groups, but then abruptly, it stopped syncing with below error.
Processor BuiltinKindsEntityProcessor threw an error while validating the entity group:default/mainstream-engineering-admin; caused by TypeError: /spec/members/2 must be string - type: string entity=group:default/mainstream-engineering-admin [36mlocation[39m=url:https://authusqa.devops.sws.company.com/auth/admin/realms/chim/groups/480049ad-7a33-41ab-87a6-382a797831e0
I am using the new backend and followed the plugin configuration steps accordingly.
Expected Behavior
All users and groups from keyclock realm should be synced
What are the steps to reproduce this bug?
Versions of software used and environment
@janus-idp/backstage-plugin-keycloak-backend": "^1.13.1",
Backstage - 1.30.4 (create-app@0.5.18)