@devries-cameron20 / t3code-1 / commits / 16548ab8a4
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(azure-devops): issue list loads work items through workitemsbatch (#38019)

Julius Marminge committed Nov 17, 2026 at 01:11 UTC 16548ab8a4a4af0e437845ee38091b4a95693be4
3 files changed +49 -34
packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.test.ts
+34 -20
@@ -222,27 +222,41 @@ describe("AzureDevOpsIssueTracker", () => {
222 const api = yield* AzureDevOpsIssueTracker.make.pipe(
223 Effect.provide(
224 Layer.mock(AzureDevOpsCli.AzureDevOpsCli)({
225 - execute: ({ args }) =>
226 - args[args.indexOf("--resource") + 1] === "wiql"
227 - ? fs.readFileString(args[args.indexOf("--in-file") + 1]!).pipe(
228 - Effect.orDie,
229 - Effect.map((body) => {
230 - bodies.push(body);
231 - return TestSourceControlHost.processOutput(
232 - encode({ workItems: [{ id: 9 }, { id: 7 }, { id: 3 }] }),
233 - );
234 - }),
235 - )
236 - : Effect.sync(() => {
237 - if (args[args.indexOf("--resource") + 1] !== "workitems") {
238 - return TestSourceControlHost.processOutput(answer(args));
239 - }
240 - hydrated.push(args.find((arg) => arg.startsWith("ids=")) ?? "");
241 - // The page as REST answers it: an envelope, in an order of its own.
225 + execute: ({ args }) => {
226 + const resource = args[args.indexOf("--resource") + 1];
227 + if (resource === "workitems") {
228 + // `az devops invoke` resolves `wit/workitems` to the create route
229 + // (`.../workitems/${type}`) and fails before sending anything.
230 + return Effect.fail(
231 + new AzureDevOpsCli.AzureDevOpsCommandFailedError({
232 + operation: "execute",
233 + command: "az",
234 + cwd: "/w",
235 + argumentCount: args.length,
236 + cause: "KeyError: 'type'",
237 + }),
238 + );
239 + }
240 + if (resource !== "wiql" && resource !== "workitemsbatch") {
241 + return Effect.succeed(TestSourceControlHost.processOutput(answer(args)));
242 + }
243 + return fs.readFileString(args[args.indexOf("--in-file") + 1]!).pipe(
244 + Effect.orDie,
245 + Effect.map((body) => {
246 + if (resource === "wiql") {
247 + bodies.push(body);
248 return TestSourceControlHost.processOutput(
243 - encode({ count: 2, value: [WORK_ITEM, { ...WORK_ITEM, id: 9 }] }),
249 + encode({ workItems: [{ id: 9 }, { id: 7 }, { id: 3 }] }),
250 );
245 - }),
251 + }
252 + hydrated.push((JSON.parse(body) as { ids: number[] }).ids.join(","));
253 + // The page as REST answers it: an envelope, in an order of its own.
254 + return TestSourceControlHost.processOutput(
255 + encode({ count: 2, value: [WORK_ITEM, { ...WORK_ITEM, id: 9 }] }),
256 + );
257 + }),
258 + );
259 + },
260 }),
261 ),
262 );
@@ -260,7 +274,7 @@ describe("AzureDevOpsIssueTracker", () => {
274 cursor: "2026-07-01T00:00:00Z|7",
275 });
276 // The rows come back in WIQL's order, and the cursor is the last one of the page.
263 - expect(hydrated).toEqual(["ids=9,7"]);
277 + expect(hydrated).toEqual(["9,7"]);
278 expect(page.items.map((item) => item.key)).toEqual(["9", "7"]);
279 expect(page.nextCursor).toBe("2026-07-01T00:00:00Z|7");
280 expect(bodies).toHaveLength(1);
packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.ts
+14 -13
@@ -661,22 +661,23 @@ export const make: Effect.Effect<
661 Effect.flatMap((ids) =>
662 ids.length === 0
663 ? Effect.succeed({ items: [], nextCursor: null })
664 - : read({
664 + : invokeWithBody({
665 cwd: input.cwd,
666 operation: "listIssues",
667 - args: invokeArgs({
668 - ...scope,
669 - resource: "workitems",
670 - query: [
671 - `ids=${ids
672 - .slice(0, limit)
673 - .map((row) => row.id)
674 - .join(",")}`,
675 - `fields=${LIST_FIELDS.join(",")}`,
676 - ],
677 - }),
678 - decode: (raw) => decodeWorkItemsJson(raw, closed),
667 + // az resolves `wit/workitems` to the create route (`workitems/${type}`)
668 + // and fails before sending; `workitemsbatch` has a single route.
669 + args: invokeArgs({ ...scope, resource: "workitemsbatch", method: "POST" }),
670 + body: {
671 + ids: ids.slice(0, limit).map((row) => row.id),
672 + fields: LIST_FIELDS,
673 + },
674 }).pipe(
675 + Effect.flatMap((raw) => {
676 + const decoded = decodeWorkItemsJson(raw, closed);
677 + return Result.isSuccess(decoded)
678 + ? Effect.succeed(decoded.success)
679 + : Effect.fail(unreadable("listIssues", decoded.failure));
680 + }),
681 Effect.map((hydrated) => {
682 // The cursor is the last row WIQL sorted, so its order is restored.
683 const position = new Map(ids.map((row, index) => [String(row.id), index]));
packages/source-control-azure-devops/src/server/azureDevOpsIssueJson.ts
+1 -1
@@ -219,7 +219,7 @@ export function workItemStates(
219 return states.some((state) => state.name === item.state.name) ? states : [...states, item.state];
220 }
221
222 -/** The `{ count, value }` page `wit/workitems` answers; a row this cannot place is skipped. */
222 +/** The `{ count, value }` page `wit/workitemsbatch` answers; a row this cannot place is skipped. */
223 export function decodeWorkItemsJson(
224 raw: string,
225 closed: ClosedStates,