2.36.12 - Some Data Elements not loading in maintenance app

It seems to be some sort of front-end issue - The API returns the data element just fine and I can’t find any errors in the DHIS2 logs. The only error is from the JS console:

drop-down.js:54 Uncaught TypeError: Cannot read properties of undefined (reading ‘text’)
at r.getOptionText (drop-down.js:54:62)
at t.value (drop-down.js:170:33)
at t.value (drop-down.js:210:24)
at d._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js:799:1)
at d._renderValidatedComponent (ReactCompositeComponent.js:822:1)
at d.performInitialMount (ReactCompositeComponent.js:362:1)
at d.mountComponent (ReactCompositeComponent.js:258:1)
at Object.mountComponent (ReactReconciler.js:46:1)
at h.mountChildren (ReactMultiChild.js:238:1)
at h._createInitialChildren (ReactDOMComponent.js:697:1)
at h.mountComponent (ReactDOMComponent.js:516:1)
at Object.mountComponent (ReactReconciler.js:46:1)
at h.mountChildren (ReactMultiChild.js:238:1)
at h._createInitialChildren (ReactDOMComponent.js:697:1)
at h.mountComponent (ReactDOMComponent.js:516:1)
at Object.mountComponent (ReactReconciler.js:46:1)
at d.performInitialMount (ReactCompositeComponent.js:371:1)
at d.mountComponent (ReactCompositeComponent.js:258:1)
at Object.mountComponent (ReactReconciler.js:46:1)
at h.mountChildren (ReactMultiChild.js:238:1)
at h._createInitialChildren (ReactDOMComponent.js:697:1)
at h.mountComponent (ReactDOMComponent.js:516:1)
at Object.mountComponent (ReactReconciler.js:46:1)
at d._updateRenderedComponent (ReactCompositeComponent.js:765:1)
at d._performComponentUpdate (ReactCompositeComponent.js:724:1)
at d.updateComponent (ReactCompositeComponent.js:645:1)
at d.performUpdateIfNecessary (ReactCompositeComponent.js:561:1)
at Object.performUpdateIfNecessary (ReactReconciler.js:157:1)
at u (ReactUpdates.js:150:1)
at o.perform (Transaction.js:140:1)
at r.perform (Transaction.js:140:1)
at r.perform (ReactUpdates.js:89:1)
at Object.S [as flushBatchedUpdates] (ReactUpdates.js:172:1)
at o.closeAll (Transaction.js:206:1)
at o.perform (Transaction.js:153:1)
at Object.batchedUpdates (ReactDefaultBatchingStrategy.js:62:1)
at Object.l [as enqueueUpdate] (ReactUpdates.js:200:1)
at o (ReactUpdateQueue.js:24:1)
at Object.enqueueSetState (ReactUpdateQueue.js:219:1)
at o.setState (ReactComponent.js:63:1)
at t._next (EditModelForm.component.js:141:22)
at t.__tryOrUnsub (Subscriber.js:242:1)
at t.next (Subscriber.js:189:1)
at t._next (Subscriber.js:129:1)
at t.next (Subscriber.js:93:1)
at t._next (map.js:85:1)
at t.next (Subscriber.js:93:1)
at t._next (filter.js:89:1)
at t.next (Subscriber.js:93:1)
at t.notifyNext (combineLatest.js:133:1)
at t._next (InnerSubscriber.js:23:1)
at t.next (Subscriber.js:93:1)
at t.notifyNext (mergeMap.js:145:1)
at t._next (InnerSubscriber.js:23:1)
at t.next (Subscriber.js:93:1)
at i.schedule.value (PromiseObservable.js:66:1)

Thank you @chase.freeman! What version of dhis2 are you using? Would it be possible to reproduce the issue on play? Is there a way to debug the issue and get more info. The ‘Cannot read properties of undefined’ is usually generic error and doesn’t indicate what the issue is exactly.

Are you able to identify which Data Elements are not loading? Maybe this will give us an insight.

Thanks!

Can you recreate this on play @chase.freeman (if yes, please open a jira or let us know the data element)?

If not, it might be caused by the data element being associated with an invalid optionSet (e.g. on e that’s been deleted), or maybe the option set is not being returned by the api call to optionSets in the maintenance app.

1 Like

Thanks @tzemp - I’ve investigated the optionSets but no luck (yet). I think I need to look at them again with fresh eyes. I cannot recreate on Play.

1 Like

This it the line of code that is failing: maintenance-app/src/forms/form-fields/drop-down.js at v36 · dhis2/maintenance-app · GitHub

Sorry, I just looked at it very briefly yesterday and assumed options/optionSets, but it probably actually applies to any drop down on a data element page. So, there’s somewhere where you have this.state.options.find(option => option.value === value) evaluating to undefined and hence undefined has no property text.

Maybe check the other dropdown items and check that all of the values associated with the data element are valid (e.g. they exist in the dropdown)? I assume this is a metadata issue if you cannot create on play, but possibly there’s also something going wrong with the value that is being passed to this component.

Let us know in case there’s something for us to fix

1 Like

Indeed, this was my assumption, too. Thanks you for providing exactly what I need to look at, that is helpful. I was mostly wondering if anyone had seen this before. I’ll dig in further to see what I can ascertain. Thanks Tom!

1 Like

@tzemp I have identified that it is a certain option set which is assigned to an attribute that is causing the error when loading a data element page in maintenance. Futhermore, it seems related to this issue: [DHIS2-14454] - Jira as the error is nearly the same (swap “code” for “text”) and both have to do with the UI reading option set/options. I have yet to determine what he issue is but by removing the option set from the attribute, the data element loads which is a fine work around but not sustainable.

I’m going to keep digging and I’ll report back if I find anything.

Likely related: Error in generating Event Report for any data element linked with the Option set - #9 by tawanda

Chase

Thanks @tzemp and @chase.freeman!

Was a jira issue created for this issue? Any new updates?

Thanks!

No - I have not created a jira ticket because I don’t know how to reproduce it on play (I’m not sure of the root cause - just that it is related to an option set)

Thanks Chase for the update. Just to confirm: is the option set that is assigned to the data element present in api/optionSets (or more specifically in the request made by maintenance app when you look in the network tab)?

I’m not sure if that ticket you’ve linked is related and haven’t looked at it in detail, but it’s pretty common to get something undefined and then we try to read a property from it. So it could just be a problem that looks similar, or it could be there’s a common issue with what’s being returned by the api.

I don’t think we want to update anything in the maintenance app until we have something we can create on play/dev. But if we can recreate, we will fix it. I’m sorry that it’s not easier to point you in a direction to recreate it, but looking at the code for this specific issue, there’s not anything that jumps out at me that is going wrong (without there being some kind of metadata issue).

Right - I wouldn’t update anything in the maintenance app. I’ve just been investigating in order to try and find a way to unwind this problem and hopefully stop it from happening again.

You’re right though, most likely not related to the other ticket but the overlapping outcomes on the same metadata were worth looking into.

Lastly, yes everything was represented in the api/the request from network tab.