-
Notifications
You must be signed in to change notification settings - Fork 2
refactor: clean up duplicate api structs #407
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @ilblackdragon, 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 undertakes a significant refactoring effort to streamline the API's data model definitions. By centralizing core structs and enums related to responses and conversations within the Highlights
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
|
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 effectively centralizes API data structures in the services crate, reducing duplication and improving maintainability, and moves validation logic to reside with the data structures. However, a critical security oversight has been identified in the create_conversation_items route: the metadata field for individual conversation messages is processed without size validation, which could lead to resource exhaustion attacks. This needs to be addressed. On a positive note, the addition of annotations to MCP tools and new tests for backward compatibility and validation are valuable improvements. I also have one minor suggestion for simplification.
| content, | ||
| model, | ||
| .. | ||
| metadata, |
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 metadata field in ConversationInputItem::Message is now being extracted and processed, but it lacks size validation. Other similar metadata fields in the API (e.g., in CreateConversationRequest and UpdateConversationRequest) are validated against MAX_METADATA_SIZE_BYTES (16KB) to prevent database abuse and resource exhaustion. Since a single create_conversation_items request can contain up to 20 items, each with its own metadata, failing to validate the size could lead to significant database bloat or memory issues.
Resolved conflicts: - models.rs: Keep both mutual exclusivity validation and message metadata size validation - service.rs: Pass through metadata field instead of hardcoding None Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Consolidates repeated JSON size validation logic into a single reusable function in common.rs. Reduces duplication across CreateResponseRequest, CreateConversationRequest, and UpdateConversationRequest validation. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add `..` to ignore metadata field in pattern match - Export ResponseOutputContent from api::models - Fix tests to use ResponseContentItem instead of ResponseOutputContent Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ous_response_id These fields serve different purposes and should be allowed together: - conversation.id: specifies which conversation the response belongs to - previous_response_id: specifies which response to branch from (for branching conversations) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Builds on top of #375 - merge it first and refresh this