From a9bfd5d4af8ed00a8fc7ca121a38afd46dbed211 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 4 Apr 2026 17:40:37 +0000 Subject: [PATCH 1/3] Initial plan From e3ba59203f4a9967d5e7efdc31b172ce141da2c9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 4 Apr 2026 17:43:34 +0000 Subject: [PATCH 2/3] fix: guard GitHub repos slicing against non-array responses Agent-Logs-Url: https://github.com/Yasar2019/myPortfolio/sessions/2b4c41be-e18d-4865-98f8-0676d7aa2dfc Co-authored-by: Yasar2019 <60102921+Yasar2019@users.noreply.github.com> --- src/Components/GithubRepos.jsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Components/GithubRepos.jsx b/src/Components/GithubRepos.jsx index 354c9a6..b4e5d48 100644 --- a/src/Components/GithubRepos.jsx +++ b/src/Components/GithubRepos.jsx @@ -50,8 +50,15 @@ const GithubRepos = () => { useEffect(() => { fetch("https://api.github.com/users/Yasar2019/repos") - .then((response) => response.json()) - .then((data) => setRepos(data.slice(0, 5))) // Fetch latest 5 repos + .then(async (response) => { + const data = await response.json(); + + if (!response.ok || !Array.isArray(data)) { + throw new Error("Invalid GitHub repos response"); + } + + setRepos(data.slice(0, 5)); // Fetch latest 5 repos + }) .catch((error) => console.error("Error fetching repos:", error)); }, []); From 96bcd620cd8f33cf644e3bae4d2a9a69e7731f83 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 4 Apr 2026 17:47:48 +0000 Subject: [PATCH 3/3] refactor: split GitHub API error guards by response and data shape Agent-Logs-Url: https://github.com/Yasar2019/myPortfolio/sessions/2b4c41be-e18d-4865-98f8-0676d7aa2dfc Co-authored-by: Yasar2019 <60102921+Yasar2019@users.noreply.github.com> --- src/Components/GithubRepos.jsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Components/GithubRepos.jsx b/src/Components/GithubRepos.jsx index b4e5d48..5435350 100644 --- a/src/Components/GithubRepos.jsx +++ b/src/Components/GithubRepos.jsx @@ -50,11 +50,16 @@ const GithubRepos = () => { useEffect(() => { fetch("https://api.github.com/users/Yasar2019/repos") - .then(async (response) => { - const data = await response.json(); + .then((response) => { + if (!response.ok) { + throw new Error("GitHub API request failed"); + } - if (!response.ok || !Array.isArray(data)) { - throw new Error("Invalid GitHub repos response"); + return response.json(); + }) + .then((data) => { + if (!Array.isArray(data)) { + throw new Error("GitHub API returned invalid data format"); } setRepos(data.slice(0, 5)); // Fetch latest 5 repos