Skip to content

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

Merged
merged 2 commits into from
Jul 15, 2025

Conversation

nini22P
Copy link
Contributor

@nini22P nini22P commented Jul 12, 2025

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.

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 new JsonApi content type, and refines HttpClient logic for better FormData handling and content type header setting.
  • Game List API Robustness: The GameInfoDto now allows its template property to be null, and the getGameList service method has been made more robust by checking for the existence of template.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

  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.

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

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 } : {}),

Choose a reason for hiding this comment

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

critical

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.

Suggested change
...(type ? { "Content-Type": type } : {}),
...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}),

Comment on lines +41 to +46
if (await this.webgalFs.exists(configFilePath)) {
const templateConfigString = await this.webgalFs.readTextFile(
configFilePath,
);
templateConfig = JSON.parse(templateConfigString as string);
}

Choose a reason for hiding this comment

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

medium

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);
          }

@MakinoharaShoko MakinoharaShoko merged commit e5b75d3 into OpenWebGAL:dev Jul 15, 2025
6 checks passed
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