-
-
Notifications
You must be signed in to change notification settings - Fork 66
Fix game list api and openapi generation command #448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
nini22P
commented
Jul 12, 2025
- 修复 游戏列表接口无法展示没有模板文件 template.json 的游戏。 #442
- 修复 openapi 生成指令
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @nini22P, 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 primarily focuses on improving the stability and correctness of the application's API interactions. It updates the OpenAPI client generation process and enhances the game list API to gracefully handle cases where game template configurations might be missing, resolving a reported issue.
Highlights
- OpenAPI Generation Command Fix: The command used to generate the OpenAPI TypeScript client has been updated to include the
generate
subcommand, ensuring proper client code generation. - Generated API Client Updates: The auto-generated API client (
Api.ts
) now includes a@ts-nocheck
directive to suppress TypeScript errors, standardizes string literal quotes, adds a newJsonApi
content type, and refinesHttpClient
logic for betterFormData
handling and content type header setting. - Game List API Robustness: The
GameInfoDto
now allows itstemplate
property to benull
, and thegetGameList
service method has been made more robust by checking for the existence oftemplate.json
before attempting to read it. This prevents errors when a game does not have an associated template configuration, addressing issue #442.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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 is currently in preview and 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 to provide feedback.
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
-
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. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request fixes an issue with the game list API and the OpenAPI generation command. A critical issue was identified in how FormData
requests are handled which will likely break file uploads, and a medium-severity race condition was identified and a fix suggested to make the code more robust.
body = JSON.stringify(body); | ||
} | ||
|
||
return this.instance.request({ | ||
...requestParams, | ||
headers: { | ||
...(requestParams.headers || {}), | ||
...(type && type !== ContentType.FormData ? { 'Content-Type': type } : {}), | ||
...(type ? { "Content-Type": type } : {}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Content-Type
header is being explicitly set for all request types. When using FormData
, axios
automatically sets the Content-Type
header to multipart/form-data
along with the required boundary
parameter. By explicitly setting the Content-Type
for all types, you are overriding axios
's behavior. For FormData
, this will result in a Content-Type
header without the boundary
, causing the server to be unable to parse the request body. Revert to a similar logic that excludes ContentType.FormData
from this header modification.
...(type ? { "Content-Type": type } : {}), | |
...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), |
if (await this.webgalFs.exists(configFilePath)) { | ||
const templateConfigString = await this.webgalFs.readTextFile( | ||
configFilePath, | ||
); | ||
templateConfig = JSON.parse(templateConfigString as string); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using webgalFs.exists()
followed by webgalFs.readTextFile()
introduces a time-of-check-to-time-of-use (TOCTOU) race condition. It's possible for the file to be deleted or modified between the existence check and the read operation, which could lead to an unhandled error. Attempt to read the file directly and handle the outcome. Rely on the return value of readTextFile
to determine if the file was present and read successfully. This avoids the race condition.
let templateConfig: TemplateConfigDto = null;
const configFilePath = this.webgalFs.getPathFromRoot(
`/public/games/${gameDir}/game/template/template.json`,
);
const templateConfigString = await this.webgalFs.readTextFile(
configFilePath,
);
if (templateConfigString !== 'file not exist') {
templateConfig = JSON.parse(templateConfigString as string);
}