dhis3/go
craftclinical-safetyDHIS2

The Rule the Phone Ignores

On the twenty-eighth of October, a DHIS2 implementer filed a report that version 3.5.0 of the Android Capture app was silently dropping one kind of program-rule action when another kind of program-rule action was also attached to the same field. The web client did the right thing with the same configuration. The phone did not. The fix shipped a week later in version 3.5.1, and the specific moment in which this kind of bug was filed is the subject of this post, because it is the third one of its kind the journal has had reason to write about in five weeks.

The specific divergence

The affected action is HIDEFIELD. A program rule can attach a HIDEFIELD effect to a data-entry field, which tells the client to not render the field at all for a given context; the rule is a common mechanism for implementing conditional data-entry forms. The bug: on Android 3.5.0, when a given field was targeted by both a HIDEFIELD rule and an option-targeting rule (HIDEOPTION, HIDEOPTIONGROUP, or SHOWOPTIONGROUP), the HIDEFIELD action was silently ignored regardless of rule priority. The field rendered. The option-targeting rule did whatever it was going to do. Nothing in the UI told the user that a HIDEFIELD effect was supposed to have fired.

The web client, under the same metadata, hid the field correctly.

A fix was merged into dhis2/mobile-capture and shipped as 3.5.1 the following week. The PR number is 5297. No workaround was documented for existing 3.5.0 installs beyond upgrading.

The pattern underneath

What is interesting about this filing is not the bug (which was caught and fixed on a normal cadence) but the fact that it is the third report in five weeks of a specific category: the program-rule engine on one DHIS2 client behaving differently from the program-rule engine on another DHIS2 client under configurations that the specification does not explicitly address.

The first scan that surfaced the pattern was the v42.7 z-score correction on the twenty-second of October, in which three child-nutrition z-score functions were aligned to WHO Anthro output after historical calculations had diverged. The second was the d2:validatePattern breaking change on the same release, which adjusted the semantics of a regex-validation rule across versions 42.7, 41.9, 42.6, 43.2, and Android 3.4.2. This Android 3.5.0 HIDEFIELD conflict is the third.

The three findings are not the same bug. They are three instances of the same underlying absence. The DHIS2 program-rule engine is implemented in multiple places (in the web client, in the Android Capture app, in the server-side rules runner that fires rules during data submission) and its specification does not, as far as the public documentation goes, explicitly resolve the edge cases where two rule actions interact on the same field.

What this means for the port

The DHIS3/go port has not reached the program-rules engine. Its current sweep is on the ACL predicate, which is not a rules-engine concern. When the port does reach the rules engine (it is one of the surfaces the project will have to reimplement if the Go gateway is to serve as a strangler-fig replacement for the Java server) it will confront the same question the three scans have surfaced: what are the semantics of two rule actions interacting on the same field? The port cannot answer the question by reading the Java source alone; the Java source and the Android source currently disagree. The port will need, in order to behave correctly, a specification of the kind the sector has not yet written.

This is a real gap. It is also the kind of gap a port is well-positioned to help close: an implementation that has to make the specification explicit (because it has to produce byte-equal output under a parity harness) has an interest the existing implementations have not quite had. The Go port can, when it reaches the rules engine, write down what the rules engine actually does, and submit that writing as a contribution to a specification the sector has needed for a decade.

A bug that gets fixed is an event. A pattern of similar bugs is a signal. The signal the sector is sending itself, over the past five weeks, is that it is time to write the program-rule specification down.