Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rules returning null in decisions. #236

Open
ghost opened this issue Nov 5, 2019 · 2 comments
Open

Rules returning null in decisions. #236

ghost opened this issue Nov 5, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Nov 5, 2019

Reproduction steps

  1. Write a decision rule that returns null as a decision object.
  2. Run the workflow(registration/enrolment/encounter) that invokes the rule written in step 1 on the android app.
  3. If the rule is written in the old style then the app will crash but if the rule is written in a new style then the rule will be ignored silently and there will be a cryptic error in RuleFailureTelemetry.

Expected Behaviour
This is an error that we can easily validate so we should notify the implementer using rule failure telemetry with a clear message that their rule returns null object so they can fix their rule. Right now the app behaviour is to crash(if old rule) or ignore silently and give cryptic null pointer error message in rule failure telemetry(if new rule).

See RuleEvaluationService.js
validateDecisions(d, ruleUUID, individualUUID) {
    return _.merge(..._.map(d, (decisions, decisionType) => {
        return {
            [decisionType]: decisions.filter(obj => this.checkConceptForRule(obj.name, ruleUUID, individualUUID))
                .map(obj => this.filterValues(obj, ruleUUID, individualUUID))

        }
    }));
}

Error

TypeError
/Users/vinay/code/sf/openchs-client/packages/openchs-android/src/service/RuleEvaluationService.js:106
Fatal error: null is not an object (evaluating 't.name')
Nov 5th, 2019, 11:21:08 IST

STACKTRACE

TypeError Fatal error: null is not an object (evaluating 't.name') 
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/src/service/RuleEvaluationService.js:106:85 
    [native code] filter
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/src/service/RuleEvaluationService.js:106:49 
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/lodash/lodash.js:3549:35 
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/lodash/lodash.js:4911:23 
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/lodash/lodash.js:2996:31 baseForOwn
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/lodash/lodash.js:4880:26 
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/lodash/lodash.js:3548:15 baseMap
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/lodash/lodash.js:9556:18 map
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/src/service/RuleEvaluationService.js:104:32 value
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/src/service/RuleEvaluationService.js:92:46 
    [native code] reduce
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/src/service/RuleEvaluationService.js:90:20 value
    [native code] value
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/src/service/RuleEvaluationService.js:132:38 value
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/src/state/ProgramEncounterState.js:73:49 value
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/src/state/AbstractDataEntryState.js:125:45 value
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/src/action/program/ProgramEncounterActions.js:61:40 value
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/src/reducer/Reducer.js:23:44 
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/redux/lib/combineReducers.js:132:36 
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/redux/lib/createStore.js:179:36 dispatch
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/src/framework/view/AbstractComponent.js:56:15 value
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/src/views/program/ProgramEncounterView.js:69:28 value
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/src/views/program/ProgramEncounterView.js:139:45 func
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/src/views/common/WizardButtons.js:59:54 onPress
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/Components/Touchable/TouchableNativeFeedback.android.js:213:45 touchableHandlePress
    [native code] touchableHandlePress
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/Components/Touchable/Touchable.js:878:34 _performSideEffectsForTransition
    [native code] _performSideEffectsForTransition
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/Components/Touchable/Touchable.js:777:44 _receiveSignal
    [native code] _receiveSignal
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/Components/Touchable/Touchable.js:488:24 touchableHandleResponderRelease
    [native code] touchableHandleResponderRelease
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-prod.js:48:15 invokeGuardedCallbackImpl
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-prod.js:66:34 invokeGuardedCallback
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-prod.js:79:30 invokeGuardedCallbackAndCatchFirstError
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-prod.js:173:42 executeDispatch
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-prod.js:222:24 executeDispatchesAndReleaseTopLevel
    [native code] forEach
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-prod.js:206:35 forEachAccumulated
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-prod.js:1064:26 
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-prod.js:7078:14 _batchedUpdatesImpl
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-prod.js:1025:31 batchedUpdates
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-prod.js:1045:17 _receiveRootNodeIDEvent
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-prod.js:1110:30 receiveTouches
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:366:47 value
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:106:26 
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:314:8 value
    /Users/vinay/code/sf/openchs-client/packages/openchs-android/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:105:17 value
    [native code] value

THREADS
......
......
@ghost ghost added the bug label Nov 5, 2019
@hithacker
Copy link
Collaborator

Time estimate: 2 hours. Point estimate: 1.

@vinayvenu vinayvenu added this to the Jun28-Jul16 milestone Jun 29, 2021
@arjunk arjunk removed this from the Jun28-Jul16 milestone Jul 1, 2021
@vinayvenu vinayvenu moved this to New Issues in Avni Product Jun 15, 2023
@vinayvenu vinayvenu moved this from New Issues to Analysis Complete in Avni Product Jun 23, 2023
@vinayvenu vinayvenu moved this from Analysis Complete to Ready in Avni Product Jul 6, 2023
@vinayvenu
Copy link
Member

This will need to be verified first.

@mahalakshme mahalakshme moved this from Ready to New Issues in Avni Product Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: New Issues
Development

No branches or pull requests

3 participants