Skip to content

The error handler of a microflow call rejoins after the next call when that call also has a handler and its result is read later #1994

Done

Description

@ynnckw

mxcli v0.34.0
Mendix 11.12.6

Follow-up to #1898, which v0.33.0 fixed for change. One case of the same kind is left. Take two call microflow activities with a result, each with a custom error handler, where a later statement reads the result of the second call. mxcli then stores the handler of the first call so that it rejoins after the second call, not before it. On the error path of the first call, the second call is skipped. The statement that reads its result then reads a variable that does not exist there, and mx check reports CE0108.

check and exec report nothing.

Reproduction

mdl 1;
create module MyModule;
create persistent entity MyModule.Order (
  Name: String(200)
);
create microflow MyModule.Sub () returns Boolean as $Ok begin return true; end;
create microflow MyModule.V1_ReadB ()
returns Boolean as $Ok
begin
  declare $R String = 'not run';
  $A = call microflow MyModule.Sub() on error without rollback begin
    log error node 'X' 'a';
  end error;
  $B = call microflow MyModule.Sub() on error without rollback begin
    set $R = 'threw';
  end error;
  log info node 'X' 'done {1} {2}' with ({1} = $R, {2} = toString($B));
  return true;
end;
create microflow MyModule.V2_NoRead ()
returns Boolean as $Ok
begin
  declare $R String = 'not run';
  $A = call microflow MyModule.Sub() on error without rollback begin
    log error node 'X' 'a';
  end error;
  $B = call microflow MyModule.Sub() on error without rollback begin
    set $R = 'threw';
  end error;
  log info node 'X' 'done {1}' with ({1} = $R);
  return true;
end;
create microflow MyModule.V3_SecondNoHandler ()
returns Boolean as $Ok
begin
  declare $R String = 'not run';
  $A = call microflow MyModule.Sub() on error without rollback begin
    log error node 'X' 'a';
  end error;
  $B = call microflow MyModule.Sub();
  log info node 'X' 'done {1} {2}' with ({1} = $R, {2} = toString($B));
  return true;
end;
create microflow MyModule.V4_ThenCommit ($Order: MyModule.Order)
returns Boolean as $Ok
begin
  declare $R String = 'not run';
  $A = call microflow MyModule.Sub() on error without rollback begin
    log error node 'X' 'a';
  end error;
  commit $Order on error without rollback begin
    set $R = 'threw';
  end error;
  log info node 'X' 'done {1}' with ({1} = $R);
  return true;
end;

Stored sequence flows of V1_ReadB (read from the unit after exec)

From To
call A call B
call A (error) handler A (log error 'a')
call B merge 1
call B (error) handler B (set $R)
handler A merge 1 (after call B)
merge 1 log info reading $B
log info merge 2
handler B merge 2
merge 2 end

mx check reports: CE0108 "Variable 'B' is defined but not in scope at this location." at Log message activity 'Log message (info)'.

Handler B rejoining after the log info is expected, since $B does not exist after call B fails. Handler A should rejoin before call B, because nothing reads $A.

The other three flows

Flow Handler A rejoins
V2_NoRead: as V1_ReadB, but the log info does not read $B correctly, right after call A
V3_SecondNoHandler: call B has no handler, log info reads $B correctly, right after call A
V4_ThenCommit: a commit with a handler instead of call B correctly, right after call A

mx check reports CE0108 only for V1_ReadB.

Expected

Handler A rejoins directly after call A, as it does in the other three flows.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions