Validation on `patient_id` not working with muting (SMS)

Describe the Bug
Validation for the patient_id field is not working with muting.

How To Reproduce The Issue

  1. Add a muting configuration
  2. Add a validation rule for patient_id field. e.g.
    "rule": "regex('^[0-9]{5,13}$')"
  3. Send a message that should fail the above rule. e.g.
    OFF abc
  4. See the reports, the above validation rule is ignored

Expected Behavior
Until 3.9, we used to get the error specified in the validation rule. e.g. Please ensure that the ID is correct and is between 5 to 13 digits.

Screenshots
Until 3.9: correct error message related to the validation

From 3.12: error only because the patient ID was not found

Environment

  • Instance: Local
  • Browser: Chrome
  • Client platform: Chrome
  • App: webapp
  • Version: 3.12.0 - 3.14.2 (working fine on 3.9.0)

Hi @binod

Can you please share the exact configuration you are using? Thanks!

Oh, nevermind. I see where this is coming from.

This is because we stop execution and add an error if we did not find the subject, before we actually pass the report through validations: cht-core/shared-libs/transitions/src/transitions/muting.js at 52605ac752bb40ab61ee1198fd7fe1bc0fbef982 · medic/cht-core · GitHub

(The subject is hydrated before the report actually gets to the transition and we can check directly).

We have been using update_notifications transition (which is deprecated in the favor of muting) in many SMS projects. We don’t have this problem in the update_notifications.

Should we move to muting after communicating with the partner that the error messages will be less specific, or keep using update_notifications? What do you suggest?

It’s fairly easy to restore the previous functionality (with the validation error added before checking for patient), but does require a release.

I can’t advise to use update_notifications, it’s deprecated and has not received updates and does not offer all functionality that muting offers (for example, muting will mute all contacts that are newly created under a muted place!).

Are the specific messages about the patient_id validation critical?

Are the specific messages about the patient_id validation critical?

Need to check with the partner or the delivery team, but I think there will be concerns because they are used to getting specific error messages. We can wait until the next release.