* Fetches full field details for a batch of work item IDs (max 200 per call). * `errorPolicy: 'Omit'` keeps the batch resilient: a single inaccessible or * deleted id is dropped from the response rather than failing the whole call.
( accessToken: string, organization: string, project: string, ids: number[] )
| 611 | * deleted id is dropped from the response rather than failing the whole call. |
| 612 | */ |
| 613 | async function fetchWorkItemsBatch( |
| 614 | accessToken: string, |
| 615 | organization: string, |
| 616 | project: string, |
| 617 | ids: number[] |
| 618 | ): Promise<RawWorkItem[]> { |
| 619 | if (ids.length === 0) return [] |
| 620 | const url = `${ADO_BASE_URL}/${encodeURIComponent(organization)}/${encodeURIComponent(project)}/_apis/wit/workitemsbatch?api-version=${WORKITEMS_API_VERSION}` |
| 621 | const response = await fetchWithRetry(url, { |
| 622 | method: 'POST', |
| 623 | headers: { |
| 624 | Accept: 'application/json', |
| 625 | 'Content-Type': 'application/json', |
| 626 | Authorization: patAuthHeader(accessToken), |
| 627 | }, |
| 628 | body: JSON.stringify({ |
| 629 | ids, |
| 630 | errorPolicy: 'Omit', |
| 631 | fields: [ |
| 632 | 'System.Id', |
| 633 | 'System.Title', |
| 634 | 'System.WorkItemType', |
| 635 | 'System.State', |
| 636 | 'System.AreaPath', |
| 637 | 'System.IterationPath', |
| 638 | 'System.ChangedDate', |
| 639 | 'System.Tags', |
| 640 | 'System.Description', |
| 641 | 'Microsoft.VSTS.TCM.ReproSteps', |
| 642 | 'Microsoft.VSTS.Common.AcceptanceCriteria', |
| 643 | ], |
| 644 | }), |
| 645 | }) |
| 646 | if (!response.ok) { |
| 647 | const errorText = await response.text().catch(() => '') |
| 648 | logger.error('Failed to fetch Azure DevOps work items batch', { |
| 649 | status: response.status, |
| 650 | error: errorText, |
| 651 | }) |
| 652 | throw new Error(`Failed to fetch work items batch: ${response.status}`) |
| 653 | } |
| 654 | const data = await response.json() |
| 655 | return (data.value as RawWorkItem[] | undefined) ?? [] |
| 656 | } |
| 657 | |
| 658 | /** |
| 659 | * Reads the repository-file filter configuration from sourceConfig. |
no test coverage detected