From 34295fc9462c6665f6036ab1416d2090762abc38 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 08:58:05 +0000 Subject: [PATCH] fix: Validate GitHub API directory files response --- src/utils/documents.server.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/utils/documents.server.ts b/src/utils/documents.server.ts index 821cd4e6..6e6c730f 100644 --- a/src/utils/documents.server.ts +++ b/src/utils/documents.server.ts @@ -595,11 +595,19 @@ async function fetchApiContentsRemote( const directoryFiles = (await directoryFilesResponse.json()) as Array - file.children = await buildFileTree( - directoryFiles, - depth + 1, - `${parentPath}${file.path}/`, - ) + if (!Array.isArray(directoryFiles)) { + console.warn( + `Expected an array of files from GitHub API for directory ${file.path}, but received:\n`, + JSON.stringify(directoryFiles), + ) + // Leave file.children undefined + } else { + file.children = await buildFileTree( + directoryFiles, + depth + 1, + `${parentPath}${file.path}/`, + ) + } } result.push(file)