Skip to content

Conversation

@Turtle-Hwan
Copy link
Owner

  • default icon api token 없이도 호출 가능하도록 권한 변경

@Turtle-Hwan Turtle-Hwan self-assigned this Dec 6, 2025
@gemini-code-assist
Copy link

Summary of Changes

Hello @Turtle-Hwan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue preventing default icons from loading when creating new templates by modifying API access permissions. It introduces a dedicated function for unauthenticated API requests and updates the default icon fetching mechanism to use it. Additionally, the icon loading process in the editor context has been optimized to fetch both default and user icons in parallel, enhancing performance and reliability.

Highlights

  • Public API Request Function: A new publicRequest function has been introduced in src/apis/client.ts to handle API calls that do not require authentication tokens, ensuring public endpoints can be accessed without authorization issues.
  • Default Icon Access: The getDefaultIcons function in src/apis/icons.ts now utilizes the new publicRequest function, resolving the issue where default icons were not found when creating new templates due to missing authentication.
  • Concurrent Icon Loading: The EditorContext in src/contexts/EditorContext.tsx has been updated to fetch both default icons and user-specific icons concurrently using Promise.allSettled, improving loading efficiency and robustness by handling individual promise outcomes gracefully.
  • Improved Error Handling and Data Parsing: The logic for processing API responses for icons in EditorContext.tsx has been refined to correctly parse data and handle potential errors from Promise.allSettled results.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@Turtle-Hwan Turtle-Hwan merged commit 7d64dfd into main Dec 6, 2025
2 checks passed
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이 PR은 새 템플릿 생성 시 기본 아이콘을 불러오지 못하는 문제를 해결하기 위해, 인증 없이 기본 아이콘 API를 호출할 수 있도록 publicRequest 함수를 추가하고 이를 적용했습니다. 전반적으로 올바른 방향의 수정이지만, 새로 추가된 publicRequest 함수에서 코드 중복과 불안정한 오류 처리 방식이 발견되었습니다. 또한, EditorContext에서 Promise.allSettled를 사용하면서 API 실패 케이스를 일부 누락하여 에러가 무시될 수 있는 문제가 있습니다. 코드의 안정성과 유지보수성을 높이기 위해 제안된 사항들을 검토해주시기 바랍니다.

const data = await response.json();

if (!response.ok) {
return { success: false, status: response.status, error: { code: "ERROR", message: data.message } };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

!response.ok일 때의 오류 처리가 data.message가 항상 존재한다고 가정하고 있어 불안정합니다. 만약 에러 응답의 본문이 JSON이 아니거나 message 프로퍼티가 없다면, 에러가 발생하거나 사용자에게 도움이 되지 않는 에러 메시지가 표시될 수 있습니다. 기존 request 함수(292-298라인)처럼 상태 코드와 상태 텍스트를 포함한 폴백(fallback) 메시지를 생성하는 더 안정적인 방식으로 개선하는 것이 좋습니다.

Suggested change
return { success: false, status: response.status, error: { code: "ERROR", message: data.message } };
return { success: false, status: response.status, error: { code: String(data?.code || response.status), message: data?.message || `HTTP Error: ${response.status} ${response.statusText}` } };

Comment on lines +513 to 524
if (iconsResult.status === 'fulfilled' && iconsResult.value.success && iconsResult.value.data) {
if (Array.isArray(iconsResult.value.data)) {
defaultIcons = iconsResult.value.data;
} else if (typeof iconsResult.value.data === 'object' && 'items' in iconsResult.value.data) {
// Handle paginated response format
defaultIcons = (iconsResult.data as { items: Icon[] }).items;
defaultIcons = (iconsResult.value.data as { items: Icon[] }).items;
} else {
console.error('[EditorContext] Unexpected response structure:', iconsResult.data);
console.error('[EditorContext] Unexpected response structure:', iconsResult.value.data);
}
} else {
console.error('[EditorContext] Icons API failed:', iconsResult.error);
} else if (iconsResult.status === 'rejected') {
console.error('[EditorContext] Icons API failed:', iconsResult.reason);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Promise.allSettled의 결과를 처리할 때, API 요청이 성공적으로 처리되었지만 비즈니스 로직상 실패한 경우(즉, status'fulfilled'이지만 value.successfalse인 경우)에 대한 처리가 누락되었습니다. 이로 인해 API 에러가 발생해도 조용히 무시될 수 있습니다. iconsResultuserIconsResult 모두에 대해, fulfilled 상태이면서 successfalse일 때 에러를 기록하는 로직을 추가해야 합니다.

Suggested change
if (iconsResult.status === 'fulfilled' && iconsResult.value.success && iconsResult.value.data) {
if (Array.isArray(iconsResult.value.data)) {
defaultIcons = iconsResult.value.data;
} else if (typeof iconsResult.value.data === 'object' && 'items' in iconsResult.value.data) {
// Handle paginated response format
defaultIcons = (iconsResult.data as { items: Icon[] }).items;
defaultIcons = (iconsResult.value.data as { items: Icon[] }).items;
} else {
console.error('[EditorContext] Unexpected response structure:', iconsResult.data);
console.error('[EditorContext] Unexpected response structure:', iconsResult.value.data);
}
} else {
console.error('[EditorContext] Icons API failed:', iconsResult.error);
} else if (iconsResult.status === 'rejected') {
console.error('[EditorContext] Icons API failed:', iconsResult.reason);
}
if (iconsResult.status === 'fulfilled') {
if (iconsResult.value.success && iconsResult.value.data) {
if (Array.isArray(iconsResult.value.data)) {
defaultIcons = iconsResult.value.data;
} else if (typeof iconsResult.value.data === 'object' && 'items' in iconsResult.value.data) {
// Handle paginated response format
defaultIcons = (iconsResult.value.data as { items: Icon[] }).items;
} else {
console.error('[EditorContext] Unexpected response structure:', iconsResult.value.data);
}
} else {
console.error('[EditorContext] Default icons API failed:', iconsResult.value.error);
}
} else if (iconsResult.status === 'rejected') {
console.error('[EditorContext] Default icons API failed:', iconsResult.reason);
}

Comment on lines +374 to +405
export async function publicRequest<T = unknown>(
url: string,
method: string,
body?: unknown,
config?: RequestConfig
): Promise<ApiResponse<T>> {
try {
const { headers = {}, params } = config || {};

const urlWithParams = buildUrl(url, params);
const fullUrl = url.startsWith("http") ? urlWithParams : `${API_BASE_URL}${urlWithParams}`;

const response = await fetch(fullUrl, {
method,
headers: { "Content-Type": "application/json", ...headers },
body: body ? JSON.stringify(body) : undefined,
});

const data = await response.json();

if (!response.ok) {
return { success: false, status: response.status, error: { code: "ERROR", message: data.message } };
}

// Extract 'result' field if present (backend response format)
const resultData = data && typeof data === 'object' && 'result' in data ? data.result : data;

return { success: true, status: response.status, data: resultData as T };
} catch (error) {
return { success: false, error: { code: "NETWORK_ERROR", message: String(error) } };
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

publicRequest 함수가 기존 request 함수와 URL 생성, 응답 처리, result 필드 추출 등 많은 로직을 중복으로 가지고 있습니다. 코드 중복은 장기적으로 유지보수를 어렵게 만들 수 있습니다. request 함수에 인증을 건너뛰는 옵션(예: config: { isPublic: true })을 추가하여 로직을 통합하는 리팩토링을 고려해볼 수 있습니다. 이렇게 하면 요청 로직을 중앙에서 관리하고 일관성을 유지하는 데 도움이 됩니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants