Conversation
Summary of ChangesHello @gantoine, 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 introduces a significant architectural improvement by standardizing how form data and JSON payloads are handled in the backend API. By moving from manual request parsing to explicit FastAPI dependencies and Pydantic models, the API becomes more robust, type-safe, and self-documenting. The frontend has been comprehensively updated to consume these refined API definitions, ensuring seamless integration and leveraging the benefits of strong typing for API interactions. Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
Test Results820 tests 819 ✅ 2m 7s ⏱️ Results for commit 3fc8c68. ♻️ This comment has been updated with latest results. |
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
There was a problem hiding this comment.
Code Review
This pull request significantly refactors the backend API by replacing manual parsing with typed fields using FastAPI's Form and Pydantic models, which enhances type safety, validation, and API documentation. The frontend has been updated accordingly, including a new buildFormInput utility. However, critical security vulnerabilities were identified: Path Traversal due to a lack of sanitization for user-provided filenames in upload endpoints, and Server-Side Request Forgery (SSRF) from insufficient validation of remote URLs used to fetch covers and manuals. These could allow arbitrary file writes or access to internal network resources. It is recommended to apply filename sanitization and URL validation across all affected endpoints. Additionally, an issue was found in the frontend's updateUser API call where multipart/form-data is likely being sent with an incorrect body format.
There was a problem hiding this comment.
Pull request overview
This PR tightens request/response typing across the frontend API layer and refactors several backend endpoints to use typed FastAPI Form/File/Pydantic payloads, while also adding SSRF-focused URL validation for server-side HTTP fetches.
Changes:
- Added a typed
buildFormInputhelper and migrated several frontend API calls to use OpenAPI-generated body types + typed Axios generics. - Refactored backend endpoints (rom/collections/saves/states/screenshots/config) to use structured request parsing and introduced SSRF URL validation.
- Updated OpenAPI generated frontend types and added/expanded backend tests for new payload shapes and URL validation.
Reviewed changes
Copilot reviewed 36 out of 49 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/views/Patcher.vue | Minor TS inference tweak for Promise.allSettled responses. |
| frontend/src/utils/formData.ts | Adds typed FormData builder for safer multipart payload construction. |
| frontend/src/services/api/user.ts | Uses generated request body types and typed Axios responses; adjusts ui_settings serialization. |
| frontend/src/services/api/task.ts | Adds typed Axios generics for task endpoints. |
| frontend/src/services/api/state.ts | Switches to generated schemas and buildFormInput for multipart state uploads/updates. |
| frontend/src/services/api/sgdb.ts | Adds typed Axios generic for cover search response. |
| frontend/src/services/api/setup.ts | Replaces store types with generated schema types. |
| frontend/src/services/api/screenshot.ts | Uses generated schemas and buildFormInput for screenshot uploads/updates. |
| frontend/src/services/api/save.ts | Uses generated schemas and buildFormInput for save uploads/updates; adds typed responses. |
| frontend/src/services/api/rom.ts | Uses generated schemas, typed Axios generics, and buildFormInput for rom update multipart fields; updates user-props payload shape. |
| frontend/src/services/api/platform.ts | Uses generated body types and narrows update payload fields. |
| frontend/src/services/api/identity.ts | Adds generated body types for identity flows and typed Axios generics. |
| frontend/src/services/api/gamelist.ts | Minor signature simplification. |
| frontend/src/services/api/firmware.ts | Types firmware uploads and returns data instead of AxiosResponse. |
| frontend/src/services/api/config.ts | Adds generated payload types and typed Axios generics for config posts. |
| frontend/src/services/api/collection.ts | Uses generated schemas and buildFormInput; returns data for create endpoints; typed responses for others. |
| frontend/src/console/views/Play.vue | Uses buildFormInput for state upload multipart payload (console flow). |
| frontend/src/composables/useFavoriteToggle.ts | Updates to new collectionApi.createCollection return shape and adds explicit id typing in filters. |
| frontend/src/components/common/Platform/Dialog/UploadFirmware.vue | Updates to firmware upload returning data directly. |
| frontend/src/components/common/Game/Dialog/UploadRom.vue | Minor TS inference tweak for Promise.allSettled responses. |
| frontend/src/components/common/Game/Dialog/EditRom.vue | Minor TS inference tweak for Promise.allSettled responses. |
| frontend/src/components/common/Collection/Dialog/CreateSmartCollection.vue | Updates to new createSmartCollection return shape. |
| frontend/src/components/common/Collection/Dialog/CreateCollection.vue | Updates to new createCollection return shape. |
| frontend/src/generated/models/RomUserUpdatePayload.ts | Updates generated model name/shape for rom user props payload. |
| frontend/src/generated/models/PlatformBindingPayload.ts | Adds generated payload model for platform binding posts. |
| frontend/src/generated/models/ExclusionPayload.ts | Adds generated payload model for exclusion posts. |
| frontend/src/generated/models/Body_update_state_api_states__id__put.ts | Adds generated multipart body model for state update. |
| frontend/src/generated/models/Body_update_smart_collection_api_collections_smart__id__put.ts | Adds generated multipart body model for smart collection update. |
| frontend/src/generated/models/Body_update_save_api_saves__id__put.ts | Adds generated multipart body model for save update. |
| frontend/src/generated/models/Body_update_rom_api_roms__id__put.ts | Extends generated multipart body model for rom update fields. |
| frontend/src/generated/models/Body_update_collection_api_collections__id__put.ts | Extends generated multipart body model for collection update fields. |
| frontend/src/generated/models/Body_add_state_api_states_post.ts | Adds generated multipart body model for state upload. |
| frontend/src/generated/models/Body_add_smart_collection_api_collections_smart_post.ts | Adds generated multipart body model for smart collection create. |
| frontend/src/generated/models/Body_add_screenshot_api_screenshots_post.ts | Adds generated multipart body model for screenshot upload. |
| frontend/src/generated/models/Body_add_save_api_saves_post.ts | Adds generated multipart body model for save upload. |
| frontend/src/generated/models/Body_add_collection_api_collections_post.ts | Extends generated multipart body model for collection create fields. |
| frontend/src/generated/index.ts | Re-exports new/renamed generated models. |
| examples/config.example.yml | Clarifies commented filesystem config documentation. |
| backend/utils/validation.py | Adds SSRF-focused URL validation helper. |
| backend/tests/utils/test_validation.py | Adds comprehensive tests for SSRF URL validation behavior. |
| backend/tests/endpoints/test_rom.py | Adds tests for updated rom user-props payload envelope/flags. |
| backend/tests/endpoints/test_config.py | Adds tests validating config endpoint payload shapes. |
| backend/handler/filesystem/resources_handler.py | Validates outbound HTTP fetch URLs (covers/screens/manuals/badges/media) to mitigate SSRF. |
| backend/endpoints/states.py | Refactors state upload/update parsing to typed File params; sanitizes screenshot filename. |
| backend/endpoints/screenshots.py | Refactors screenshot upload parsing to typed File param; sanitizes screenshot filename. |
| backend/endpoints/saves.py | Refactors save upload/update parsing to typed File params; sanitizes screenshot filename. |
| backend/endpoints/rom.py | Refactors rom update to typed form parsing; adds URL validation for cover/manual/screenshots; switches rom user-props endpoint to typed payload. |
| backend/endpoints/configs.py | Refactors config mutation endpoints to typed Pydantic payloads. |
| backend/endpoints/collections.py | Refactors collection endpoints to typed form parsing; adds URL validation for cover URL. |
Files not reviewed (13)
- frontend/src/generated/index.ts: Language not supported
- frontend/src/generated/models/Body_add_collection_api_collections_post.ts: Language not supported
- frontend/src/generated/models/Body_add_save_api_saves_post.ts: Language not supported
- frontend/src/generated/models/Body_add_screenshot_api_screenshots_post.ts: Language not supported
- frontend/src/generated/models/Body_add_smart_collection_api_collections_smart_post.ts: Language not supported
- frontend/src/generated/models/Body_add_state_api_states_post.ts: Language not supported
- frontend/src/generated/models/Body_update_collection_api_collections__id__put.ts: Language not supported
- frontend/src/generated/models/Body_update_rom_api_roms__id__put.ts: Language not supported
- frontend/src/generated/models/Body_update_save_api_saves__id__put.ts: Language not supported
- frontend/src/generated/models/Body_update_smart_collection_api_collections_smart__id__put.ts: Language not supported
- frontend/src/generated/models/Body_update_state_api_states__id__put.ts: Language not supported
- frontend/src/generated/models/ExclusionPayload.ts: Language not supported
- frontend/src/generated/models/PlatformBindingPayload.ts: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 37 out of 50 changed files in this pull request and generated 12 comments.
Files not reviewed (13)
- frontend/src/generated/index.ts: Language not supported
- frontend/src/generated/models/Body_add_collection_api_collections_post.ts: Language not supported
- frontend/src/generated/models/Body_add_save_api_saves_post.ts: Language not supported
- frontend/src/generated/models/Body_add_screenshot_api_screenshots_post.ts: Language not supported
- frontend/src/generated/models/Body_add_smart_collection_api_collections_smart_post.ts: Language not supported
- frontend/src/generated/models/Body_add_state_api_states_post.ts: Language not supported
- frontend/src/generated/models/Body_update_collection_api_collections__id__put.ts: Language not supported
- frontend/src/generated/models/Body_update_rom_api_roms__id__put.ts: Language not supported
- frontend/src/generated/models/Body_update_save_api_saves__id__put.ts: Language not supported
- frontend/src/generated/models/Body_update_smart_collection_api_collections_smart__id__put.ts: Language not supported
- frontend/src/generated/models/Body_update_state_api_states__id__put.ts: Language not supported
- frontend/src/generated/models/ExclusionPayload.ts: Language not supported
- frontend/src/generated/models/PlatformBindingPayload.ts: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Greptile SummaryThis PR refactors the frontend API layer to use auto-generated typed models and a Key points from the review:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant FE as Frontend (API service)
participant EP as FastAPI Endpoint
participant VL as validate_url_for_http_request
participant DB as Database Handler
participant FS as FSResourcesHandler
Note over FE,FS: updateRom / updateCollection (cover URL path)
FE->>EP: PUT /roms/{id} (multipart form)
EP->>EP: parse_rom_update_form (Depends)
Note right of EP: Calls await request.form() again<br/>(double-parse, cached by Starlette)
EP->>DB: get_rom(id)
DB-->>EP: rom
EP->>FS: get_cover(rom, overwrite, url_cover)
FS->>VL: validate_url_for_http_request(url_cover)
alt URL is private/SSRF risk
VL-->>FS: raises ValidationError
FS-->>EP: raises ValidationError
EP->>EP: catch → HTTPException(400)
EP-->>FE: 400 Bad Request
else URL is valid
VL-->>FS: ok
FS->>FS: httpx.stream(GET, url_cover)
FS-->>EP: (path_cover_s, path_cover_l)
EP->>DB: update_rom(cleaned_data)
DB-->>EP: updated rom
EP-->>FE: 200 DetailedRomSchema
end
Note over FE,FS: add_collection (problematic path)
FE->>EP: POST /collections (multipart form)
EP->>DB: add_collection(Collection) ← committed to DB
EP->>FS: get_cover(collection, overwrite, url_cover)
FS->>VL: validate_url_for_http_request(url_cover)
alt URL is private/SSRF risk
VL-->>FS: raises ValidationError
FS-->>EP: raises ValidationError
EP->>EP: catch → HTTPException(400)
EP-->>FE: 400 Bad Request (but record already in DB!)
else URL is valid
VL-->>FS: ok
FS-->>EP: (path_cover_s, path_cover_l)
EP->>DB: update collection cover paths
EP-->>FE: 200 CollectionSchema
end
|
Description
Explain the changes or enhancements you are proposing with this pull request.
This PR tightens request/response typing across the frontend API layer and refactors several backend endpoints to use typed FastAPI Form/File/Pydantic payloads, while also adding SSRF-focused URL validation for server-side HTTP fetches.
Checklist
Please check all that apply.
Screenshots (if applicable)