feat: support onboarding ui#753
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new endpoint to list plugins by category, adds the primary task object to the plugin installation response, and includes corresponding unit tests. The review feedback suggests several improvements: refactoring the ListPlugins function to reuse the new pluginInstallationResponse struct to eliminate code duplication, guarding against negative values for skippedMatches in the service layer, making the category listing more robust by skipping plugins that fail to load instead of failing the entire request, and leveraging the oneof validator tag in the controller for category validation.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| type pluginInstallationResponse struct { | ||
| ID string `json:"id"` | ||
| Name string `json:"name"` | ||
| PluginID string `json:"plugin_id"` | ||
| TenantID string `json:"tenant_id"` | ||
| PluginUniqueIdentifier string `json:"plugin_unique_identifier"` | ||
| EndpointsActive int `json:"endpoints_active"` | ||
| EndpointsSetups int `json:"endpoints_setups"` | ||
| InstallationID string `json:"installation_id"` | ||
| Declaration *plugin_entities.PluginDeclaration `json:"declaration"` | ||
| RuntimeType plugin_entities.PluginRuntimeType `json:"runtime_type"` | ||
| Version manifest_entities.Version `json:"version"` | ||
| CreatedAt time.Time `json:"created_at"` | ||
| UpdatedAt time.Time `json:"updated_at"` | ||
| Source string `json:"source"` | ||
| Checksum string `json:"checksum"` | ||
| Meta map[string]any `json:"meta"` | ||
| } |
| return exception.BadRequestError(errors.New("invalid plugin category")).ToResponse() | ||
| } | ||
|
|
||
| skippedMatches := (page - 1) * page_size |
There was a problem hiding this comment.
If page is less than 1, skippedMatches can result in a negative value. Although the controller validates page >= 1, it is safer to guard against this in the service layer to prevent potential negative index issues if called from other contexts.
| skippedMatches := (page - 1) * page_size | |
| skippedMatches := 0 | |
| if page > 1 { | |
| skippedMatches = (page - 1) * page_size | |
| } |
| if err != nil { | ||
| return exception.InternalServerError(err).ToResponse() | ||
| } |
There was a problem hiding this comment.
If helper.CombinedGetPluginDeclaration fails for any single plugin installation (e.g., due to corrupted files or missing cache), the entire ListPluginsByCategory API will fail with a 500 Internal Server Error. To make the API more robust, consider skipping the corrupted plugin so that the rest of the tenant's plugins can still be loaded successfully.
| if err != nil { | |
| return exception.InternalServerError(err).ToResponse() | |
| } | |
| if err != nil { | |
| continue | |
| } |
| func ListPluginsByCategory(c *gin.Context) { | ||
| BindRequest(c, func(request struct { | ||
| TenantID string `uri:"tenant_id" validate:"required"` | ||
| Category plugin_entities.PluginCategory `uri:"category" validate:"required"` |
There was a problem hiding this comment.
Instead of validating the category manually in the service layer, you can leverage the oneof validator tag in the binding struct. This ensures that invalid categories are rejected immediately at the controller level.
Category plugin_entities.PluginCategory `uri:"category" validate:"required,oneof=tool model extension agent-strategy datasource trigger"`
Description
Please provide a brief description of the changes made in this pull request.
Please also include the issue number if this is related to an issue using the format
Fixes #123orCloses #123.Type of Change
Essential Checklist
Testing
Bug Fix (if applicable)
Fixes #123orCloses #123)Additional Information
Please provide any additional context that would help reviewers understand the changes.