Potential bug with api

A bit of background.

We have a new pair of programs that are used to monitor events for two separate NTDs. They track the same data for each NTD and so use the same data elements.

In some cases both NTDs are treated by the same event, so as has happened in our case, 3 IUs had a single MDA take place, but each IU generated two events, one for each NTD that was treated.

Still with me?

Ok, if I now query those two ntd events using event analytics, DHIS2’s api will give me the wrong set of rows on the second query. The metadata returned is correct, and matches the dimensions requested in the query parameters, but the dimensions in the rows will be the dimensions in the first query.

Query 1:

/api/36/analytics?dimension=dx:NF86wpe5pvS.y1nG1FiXfeA,ou:QwNGKxOonVf&startDate=2021-01-01&endDate=2021-12-31

Results meta data 1:

"metaData": {
        ...
        "dimensions": {
            "dx": [
                "NF86wpe5pvS.y1nG1FiXfeA"
            ],
            "pe": [],
            "ou": [
                "QwNGKxOonVf"
            ],
            "co": []
        }
    },

Results row data 1:

"rows": [
        [
            "NF86wpe5pvS.y1nG1FiXfeA",
            "QwNGKxOonVf",
            "1980657.0"
        ]
    ]

All working as expected. Now for query 2. Different program, same data element, and same values returned due to the quirk of both ntds being covered by the single event.

/api/36/analytics?dimension=dx:EBDCulzDKG5.y1nG1FiXfeA,ou:QwNGKxOonVf&startDate=2021-01-01&endDate=2021-12-31

Result meta data 2:

"metaData": {
        ...
        "dimensions": {
            "dx": [
                "EBDCulzDKG5.y1nG1FiXfeA"
            ],
            "pe": [],
            "ou": [
                "QwNGKxOonVf"
            ],
            "co": []
        }
    }

Result row data 2:

    "rows": [
        [
            "NF86wpe5pvS.y1nG1FiXfeA",
            "QwNGKxOonVf",
            "1980657.0"
        ]
    ]

Really bizarre. I have even tried changing the data in one of the events to make sure it isn’t because the data also matches between the two programs but even then it reports the same value for the first query. It’s clearly seems to be some sort of cache related thing, because if I give it a few minutes and then rerun the second query it actually returns the correct data elements in the rows.

I’ve tried a few different api versions (down to 33), and it appears to be happening on all of them.

Reason I spotted this is I am developing a little dashboard using Vue Js. I spend about half the day troubleshooting that before I eventually realised that the issue was actually the api. Much to my surprise.

1 Like

@HaydnJ, thank you for sharing this info, I have shared your post when I first read it, but I think it’ll be very helpful if you create a bug issue in jira.dhis2.org so that one of the developers can confirm if this is reproducible and if it’s an actual bug.

Thank you!

Hi @Gassim. Will do. I will get a an issue logged now.

Regards,
Haydn

1 Like

Thanks! I found it and added the CoP label as well as the link to this topic post, and for other users, here’s the link to the Jira bug issue: [DHIS2-12466] | Potential bug with analytics api when requesting event data from two programs that share a data element

Thanks!

BTW, make sure you check out the #copmonthly – bug hunter! :blush::+1: