We are running sonarqube 10.4, and i´d like to know if the problem describe below is a bug (and probably fixed in newest version). Here it goes:
I have what seems to be an error with using the API to fetch measures and the analysis history, for a subset of my projects. The example I have is this:
https://sonarqube.internal.is/api/measures/component?component=My.Component &metricKeys=last_commit_date
{
"component": {
"key": "My.Component",
"name": "My.Component",
"qualifier": "TRK",
"measures": [
{
"metric": "last_commit_date",
"value": "1718808384000"
}
]
}
}
Here the value for the latest commit translates to Wednesday, 19. June 2024 14:46:24, despite the latest analysis (as of 16th of January) being performed the said project on January 15, 2025 at 2:54 PM.
When the history of analysis is fetched for the SQ project is viewed:
https://sonarqube.internal.is/api/project_analyses/search?project=My.Component&category=VERSION&ps=500&p=1
{
"key": "64ad6d90-b508-416c-ab2c-b18af2c5de0a",
"date": "2024-06-19T14:49:54+0000",
"events": [
{
"key": "8c423ddf-2f25-45f1-9b5b-ef0dc3055c7f",
"category": "VERSION",
"name": "1.20.9+1697"
}
],
"projectVersion": "1.20.9+1697",
"manualNewCodePeriodBaseline": false,
"revision": "f05c37aa31407eb6d56836d6e799b90f76ee17aa",
"detectedCI": "Azure DevOps"
},
We find that the analysis closes to this date and time is the one above. The revision hash (f05c37aa31407eb6d56836d6e799b90f76ee17aa) turns out to be consistent with the underlying repository and the exact time reflected in the epoch value before.
Image
However, this is a commit and build associated with the 1.20 version of the code, while the current version is 1.29 and the version progression has been consent throughout. So no immediate explanation for the this date popping up is apparent from this evidence. Especially, when the search_history at the time of the analysis is used:
https://sonarqube.internal.is/api/measures/search_history?component=My.Component&metrics=security_hotspots,security_rating,last_commit_date &from=2025-01-15T14:54:02%2B0000&to=2025-01-15T14:54:02%2B0000
And we find that the analysis information and dates are correct for all values at this moment in time, except the last_commit_date:
{
"paging": {
"pageIndex": 1,
"pageSize": 100,
"total": 1
},
"measures": [
{
"metric": "security_rating",
"history": [
{
"date": "2025-01-15T14:54:02+0000",
"value": "1.0"
}
]
},
{
"metric": "last_commit_date",
"history": [
{
"date": "2025-01-15T14:54:02+0000",
"value": "1718808384000"
}
]
},
{
"metric": "security_hotspots",
"history": [
{
"date": "2025-01-15T14:54:02+0000",
"value": "0"
}
]
},
]
}
The same behaviour applies to only a handful of our projects, out of some hundreds. They are still enough in number to cause some difficulty with automating parts of the release pipeline. Therefore, it would be good to know if this is a bug and if there is a workaround.