Adding users as members to a group with authLib.addMembers

Enonic version: 6.15.8

I’m running a job where I need to add users as members of a group (in XP6). I found the authLib.addMembers function in!/module-auth.html#.addMembers
and tried using it like this:
In the /resources/jobs/jobs.xml i have:

  <job name="sync-job" cron="0 * * * *"/> 

where /resources/jobs/sync-job.es6 is:

const syncLib = require("../lib/syncJob/syncJob"); = () => {

and /lib/syncJob/syncJob is

const libs = {
  authutilities: require("/lib/authutilities"),
  auth: require("/lib/xp/auth")
const syncjobFunction = () => {
  libs.authutilities.runWithSystemContext(() => {
      ["", "", ""]);
exports.syncjobFunction = syncjobFunction;

and runWithSystemContext is

const runWithSystemContext = callback => ({
  principals: ["role:system.admin"]
}, callback));

First I thought maybe some of the users were not present in the userstore, but after picking users I am confident is in the userstore I am stuck again. The runWithSystemContext was necessary to avoid an error message telling me the group did not exist.
When the job containing the attempt at adding the members is done, I get the following error message:

12:03:10.056 INFO - Executed job [] in 58852 ms
12:03:12.299 WARN graphql.execution.ExecutionStrategy - Exception while fetching datacom.enonic.xp.resource.ResourceProblemException: Error: Invalid field argument keys: The number of keys must be inferior to 100 at com.enonic.xp.resource.ResourceProblemException$ at com.enonic.xp.script.impl.util.ErrorHelper.doHandleException( at com.enonic.xp.script.impl.util.ErrorHelper.handleError( at at com.enonic.lib.graphql.GraphQlBean.lambda$setFieldData$4( at graphql.execution.ExecutionStrategy.resolveField( at graphql.execution.SimpleExecutionStrategy.execute( at graphql.execution.Execution.executeOperation( at graphql.execution.Execution.execute( at graphql.GraphQL.execute( at graphql.GraphQL.execute( at com.enonic.lib.graphql.GraphQlBean.execute( at jdk.nashorn.internal.scripts.Script$Recompilation$827$2576AAA$graphql.L:1#execute( at jdk.nashorn.internal.scripts.Script$Recompilation$826$390A$graphql.L:1#L:2#post(

I also noted that graphql was mentioned in the stack trace, and as I had GraphiQL and Guillotine installed as apps in XP, I also tried to remove them to make sure they were not messing with me, but that did not help either.

Does anyone have an idea of what is happening here, and what I can do to make it work? :slightly_smiling_face:

We found the problem: the userstore I was trying to save to was one being synced over AD, which probably was not allowed for writing. When I tried to add the users as members to a group in the system user store, everything worked as expected.