Issue with statWithAuthToken function in Flow Scripting SDK

I'm using startWithAuthToken function in flow scripting SDK to start an architect session and add a flow. The issue is, If the user (whose token is used) doesn't have Architect > All Permissions then startWithAuthToken function fails but it doesn't throw any exception.

flowSession.startWithAuthToken(region, sessionStartCallback, token)
.then (r => console.log(r))
.catch (e => console.log(e));

This is how I call it and when it fails, ERROR! undefined is logged in the console but the flow doesn't come to either then or catch.

I'm using it inside an API and when this happens, the API just fails without being able to return a response. So is there any way to catch this error?

Hi @athuldilip,

We actually encountered what I believe is the same scenario you're describing in automation tests last Friday. At startup Architect Scripting checks for the architect:ui:view permission and initial investigation looks to be if the user does not have that permission, the code is invoking a generic error handler which ends up throwing but Scripting's internal generic catch error handler is not set up yet.
Additionally, you would not see an error written out to the console in this case either.

We are working on a fix and will let you know when it's out.

Thanks!

Jim

1 Like

Hi @athuldilip,

We just released Architect Scripting ver. 0.5.6 which has the updated bits to handle the case of a user that does not have the architect:ui:view permission described above.

Can you try installing and let us know if it fixes the issue you described above?

Thanks!

Jim

1 Like

Hi @Ullyot_Jim,

Thanks for the update. Now the error is logged correctly, but the execution still stops when this error is encountered. As mentioned before, when I call startWithAuthToken, the promise returned is not resolved or rejected.

This is how I'm calling it and the flow doesn't reach then or catch.

flowSession.startWithAuthToken(region, sessionStartCallback, token)
.then (r => console.log(r))
.catch (e => console.log(e));

A workaround I've found is to call /api/v2/users/{userId}/roles and check if the user has architect:ui:view before calling the startWithAuthToken.

Hi @athuldilip,

Prior to calling startWithAuthToken, are you setting endTerminatesProcess to false like this?

flowSession.endTerminatesProcess = false;

For example:

flowSession.endTerminatesProcess = false;
flowSession.startWithAuthToken(region, sessionStartCallback, token)
.then (() => {
    console.log(flowSession.endExitCode);  // 99 in this case
});

Thanks!

Jim

1 Like

Thanks a lot, @Ullyot_Jim, that solved the problem.

I was setting flowSession.endTerminatesProcess to false inside the session start callback . So in the case of an error, it wasn't executed since the callback isn't called. Setting it before startWithAuthToken, solved the problem.

Once again, thanks a lot for the help, appreciate it :smiley:

Great, glad that worked! :slight_smile:

Jim

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.