Allow partial updates to ROM user props via typed payload schema#3124
Merged
Allow partial updates to ROM user props via typed payload schema#3124
Conversation
Co-authored-by: gantoine <[email protected]>
Copilot
AI
changed the title
[WIP] [Feature] Allow partial rom properties update in API
Allow partial updates to ROM user props via typed payload schema
Mar 12, 2026
gantoine
approved these changes
Mar 12, 2026
Contributor
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
Contributor
Contributor
Greptile SummaryThis PR replaces the untyped Key changes:
Issue to address:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant Endpoint as PUT /api/roms/{id}/props
participant Pydantic as RomUserUpdatePayload
participant DB as db_rom_handler
Client->>Endpoint: JSON body (partial fields)
Endpoint->>Pydantic: Parse into RomUserUpdatePayload
Note over Pydantic: RomUserData validates each field<br/>(ge/le, enum, optional)
Pydantic-->>Endpoint: Validated payload
Endpoint->>Endpoint: payload.data.model_dump(exclude_unset=True)
Note over Endpoint: Only explicitly provided fields<br/>end up in cleaned_data
alt update_last_played = true
Endpoint->>Endpoint: cleaned_data["last_played"] = now()
else remove_last_played = true
Endpoint->>Endpoint: cleaned_data["last_played"] = None
end
Endpoint->>DB: update_rom_user(id, cleaned_data)
Note over DB: SQLAlchemy UPDATE with<br/>only the provided columns
DB-->>Endpoint: Updated RomUser
Endpoint-->>Client: RomUserSchema (200 OK)
Last reviewed commit: b1cd003 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
PUT /api/roms/{id}/propsendpoint accepted an untypeddata: dict[str, Any], making it undocumented in the OpenAPI schema and leaving users to discover the available fields by trial and error. Users were forced to re-send all fields or risk silently clearing them.Changes
RomUserDatamodel — replacesdict[str, Any]with a fully documented Pydantic model; all fields are optional to support partial updates:exclude_unset=True— endpoint now usespayload.data.model_dump(exclude_unset=True), so only explicitly provided fields are written; omitted fields are preserved, andstatus: nullstill explicitly clears the value as intendedRomUserUpdatePayload—data,update_last_played, andremove_last_playedfields now carry descriptions visible in API docstest_update_rom_user_props_partial_updateto assert that a single-field update leaves other previously set fields unchangedOriginal prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.