From 0abf16b52f10b472b03cc3faae7a578eff4a8a06 Mon Sep 17 00:00:00 2001 From: William Kelley Date: Thu, 26 Mar 2026 15:31:11 -0400 Subject: [PATCH] fix: falsy ids omitted for search params In interview, candidate encountered problem when changing `page_size` to `1` on the client. Their code was identical to the solution so something was up. Turns out the client api implementation has a bug where falsy parameters weren't serialized to the URL. Since the first project's `id` is `0`, then the offset parameter wasn't transmitted. Another invisible symptom of this bug is that the first user, "James Smith", would never work with the filter control since their `userId` was `0`. But this was never apparent because they're coded to have zero projects anyways. --- src/api/apiImpl.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/apiImpl.ts b/src/api/apiImpl.ts index 41a1a55..961ef13 100644 --- a/src/api/apiImpl.ts +++ b/src/api/apiImpl.ts @@ -18,13 +18,13 @@ class DefaultServer { }): Promise { const url = new URL('http://127.0.0.1:5000/api/projects'); - if (options?.userId) { + if (options?.userId != null) { url.searchParams.append('userId', options.userId); } - if (options?.startAfter?.id) { + if (options?.startAfter?.id != null) { url.searchParams.append('startAfterId', options.startAfter.id.toString()); } - if (options?.pageSize) { + if (options?.pageSize != null) { url.searchParams.append('pageSize', options.pageSize.toString()); }