I have noticed an issue where certain work items are missing when calling the GetWorkItemsByModuleRevisionAsync.
I have traced it back to the bulk fetch that is calling SearchWorkitemAsync which does it against the HEAD revision after the call for getting all the URIs for work item IDs and revisions for the historic revision. This means that valid work items at that historic revision that have since been moved or deleted will be lost from the results.
The fix that I found to work is simply change the call from SearchWorkitemAsync to instead use SearchWorkitemInBaselineAsync. I was able to verify manually through the UI that this returned the additional 3 items in my case that were missing but visible in the UI on the document.
SearchWorkitemInBaselineAsync on it's own with a query of the document id does return more items as it currently also includes items in the documents "Recycle Bin". However, in this GetWorkItemsByModuleRevisionAsync function the recycle bin items will be excluded by the previous step which gets the id and revision actively marked on the document and passes them explicitly in the query to the SearchWorkitemInBaselineAsync which returns the appropriate results.
Before this fix, the document and revision is questions was returning 156 work items. After the fix summary of my results:
1. GetModuleByLocationAsync("myDocument")
→ Returns module URI ✅
2. GetModuleWorkItemUrisAsync(moduleUri + "%588390")
→ Returns 159 URIs ✅ (SearchWorkitemInBaselineAsync on document id would currently return 168, 9 items in Recycle Bin included)
3. SearchWorkitemInBaselineAsync(revision, "id:(159 IDs)", fieldsList)
→ Queries baseline at revision 588390
→ Finds all 159 items ✅ (FIX WORKS CORRECTLY)
4. Process results
→ Returns 159 items with revision metadata
I have noticed an issue where certain work items are missing when calling the
GetWorkItemsByModuleRevisionAsync.I have traced it back to the bulk fetch that is calling SearchWorkitemAsync which does it against the HEAD revision after the call for getting all the URIs for work item IDs and revisions for the historic revision. This means that valid work items at that historic revision that have since been moved or deleted will be lost from the results.
The fix that I found to work is simply change the call from
SearchWorkitemAsyncto instead useSearchWorkitemInBaselineAsync. I was able to verify manually through the UI that this returned the additional 3 items in my case that were missing but visible in the UI on the document.Before this fix, the document and revision is questions was returning 156 work items. After the fix summary of my results: