Skip to content

GAZ-346: Fix ClassCastException reading id process variables in delegates - #77

Open
kanishksingh23 wants to merge 1 commit into
openMF:devfrom
kanishksingh23:fix/delegate-long-cast
Open

kanishksingh23 wants to merge 1 commit into
openMF:devfrom
kanishksingh23:fix/delegate-long-cast

Conversation

@kanishksingh23

Copy link
Copy Markdown
Contributor

What

Fixes a ClassCastException that stops multi-step workflows (e.g. client onboarding) from completing. The delegates read ID process variables with a hard (Long) cast; this replaces those with the existing ProcessVariableUtil.getLong(...) helper, which already handles Integer/Long/String/Number.

Why

Variables set from an untyped task-completion body (Map<String, Object>) deserialise JSON numbers as Integer, not Long. When a delegate then does Long clientId = (Long) execution.getVariable("clientId") it throws:

java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.Long
    at StaffAssignmentDelegate.execute(StaffAssignmentDelegate.java:38)

Reproduced end-to-end: POST /workflow/client-onboarding/start creates the client fine (typed DTO path → Long), but completing the verify task (.../tasks/{id}/complete with {"approved": true, "clientId":.., "staffId":..}) fails with 500 STAFF_ASSIGNMENT_FAILED, root cause the cast above. StaffAssignmentDelegate already coerced staffId safely via ProcessVariableUtil.getLong one line below this just applies the same treatment consistently.

Scope

Systemic: the same unsafe pattern appeared in 13 delegates (16 casts): client onboarding/activation/rejection/transfer/closure, account verification, and the loan approval/disbursement/rejection/status delegates. All switched to ProcessVariableUtil.getLong(...); import added where missing. No behavioural change beyond accepting Integer-typed IDs.

Testing

Built the image and ran a full onboarding against Fineract: authenticate → start → approve the verify task → assign staff → activate, and confirmed the client reaches Active in Fineract. Previously, this failed at the assign-staff step.

@kanishksingh23
kanishksingh23 requested a review from a team August 22, 2026 06:45
@kanishksingh23

Copy link
Copy Markdown
Contributor Author

Hey @IOhacker, please take a look when you have a moment.
Thank you.

tdaly61 added a commit to openMF/mifos-gazelle that referenced this pull request Aug 27, 2026
## Summary

Makes the Workflow Engine module demo-able end-to-end.

- Pin the fixed image `kanishksingh23/mifos-workflow:21082026`. It
includes the delegate ID cast fix
([openMF/mifos-workflow#77](openMF/mifos-workflow#77));
the previous `07082026` image threw a `ClassCastException` at the
assign-staff step, so a client onboarding could start but never
complete.
- Add `src/utils/demo-workflow.sh`, a one-command end-to-end demo:
authenticate → ensure a loan officer exists → start onboarding → approve
the verify task (assign staff + activate) → confirm the client is Active
in Fineract. Reaches the service via `kubectl port-forward`, so no
domain setup is needed.
- Document it in `docs/MIFOSX.md` (Workflow Engine section): the
one-command demo plus how to complete a task by hand.

Verified on k3s: `./src/utils/demo-workflow.sh` onboards a client all
the way to `Active`.

## Note

- The image is a personal-namespace tag for now (`kanishksingh23/…`),
same as the module's existing pin swap to `openmf/mifos-workflow` once[
#77](openMF/mifos-workflow#77) is merged and the
image is republished under the org.
- Greenbank ships no staff, so the demo creates a loan officer if none
exists (assign-staff needs one).
@kanishksingh23

Copy link
Copy Markdown
Contributor Author

Hey @tdaly61, @IOhacker, please take a look when you have a moment.
Thank you.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant