Workflows - Define Variable - Get Index always returns 0

Hi all!

It looks like the Get Index operator of the Define Variable action of Workflows is broken.

To show this, we have created a workflow with external trigger, where we pass the variable foo with value foobarfuz, then we define a variable barLocation
which is defined as the getIndex transform of this foo variable, where we search for the pattern bar. See JSON of full workflow at the bottom.

image

We test the workflow and notice the following:

Define Variable, step input:

{
  "id": "sp:define-variable",
  "variables": [
    {
      "description": "test",
      "name": "barLocation",
      "transforms": [
        {
          "id": "sp:transform:getIndex:int",
          "input": {
            "patternGetIndex": "bar"
          }
        }
      ],
      "variableA": "foobarfuz"
    }
  ]
}

Define Variable, step output:

{
  "barLocation": 0
}

We would expect the value 3 instead of 0 here, since the substring bar only appears for the first time in foobarfuz at index 3 (we expect counting to start at 0). Actually all tests so far only returns 0.

We would also expect documentation that specifies that getIndex only returns the index of the first occurance, such that foobarfuzbar gets 3 as result instead of 9.

We also would expect the documentation to mention the designed return value when the specified substring does not exists at all. Note that this can not be 0, as 0 would mean that the string starts with the given substring. Will it be -1, will it be null?

Full workflow json

{
	"name": "Angelo test workflow get index",
	"description": "test",
	"modified": "2023-11-27T10:32:51.113381604Z",
	"modifiedBy": {
		"type": "IDENTITY",
		"id": "8caf9b6efd2848c3b8b38cddae22b037",
		"name": "angelo_mekenkamp"
	},
	"definition": {
		"start": "Define Variable",
		"steps": {
			"Define Variable": {
				"attributes": {
					"id": "sp:define-variable",
					"variables": [
						{
							"description": "test",
							"name": "barLocation",
							"transforms": [
								{
									"id": "sp:transform:getIndex:int",
									"input": {
										"patternGetIndex": "bar"
									}
								}
							],
							"variableA.$": "$.trigger.foo"
						}
					]
				},
				"nextStep": "End Step — Success",
				"type": "Mutation"
			},
			"End Step — Success": {
				"type": "success"
			}
		}
	},
	"creator": {
		"type": "IDENTITY",
		"id": "8caf9b6efd2848c3b8b38cddae22b037",
		"name": "angelo_mekenkamp"
	},
	"trigger": {
		"type": "EXTERNAL",
		"attributes": {}
	}
}

Trigger input:

{
  "foo": "foobarfuz"
}

Hi @angelo_mekenkamp

I’ve created my post regarding the same issue before seeing your post:

It seems ‘Get Index’ operator doesn’t seem to be working as expected as it always return “0” value.

I hope someone from the support team would comment on this or help to resolve this ASAP.

Thanks

2 Likes

SailPoint Support said:

This was 13 days ago. I haven’t received any message from Support since.

2 Likes

Hey @angelo_mekenkamp,

I dug into this and found the issue regarding the getIndex operation.

The UI does not generate the correct JSON for getIndex, the key for where the pattern is stored is generated as patternGetIndex. Changing this key in the advanced editor tab to Pattern will give you a valid index given that the regex is correct.

I am going to create a bug ticket to get this resolved, but for now you can use this as a workaround.

2 Likes

Hi @tyler_mairose,

Thank you for your reaction and findings! SailPoint Support has meanwhile mailed me with the same message. And an hour ago they send me the bug ticket: PLTWRKFLW-3571.

1 Like

This is fixed now, @colin_mckibben, could you please add the fixed tag?

1 Like

I’ve added the tag for you. Please let me know if you need anything else. Thanks!

1 Like