Fix assignees parsing in Edit Issue (#109)

# Fix assignees parsing in EditIssueFn

## Problem
The `EditIssueFn` function in `operation/issue/issue.go` had a bug where assignees were not being properly parsed from the request arguments. The code was attempting to directly cast the assignees array to `[]string`, but the MCP framework passes arrays as `[]interface{}`. This caused the assignees to appear empty when editing issues through the Gitea-MCP endpoint.

## Solution
The assignees parsing logic in the `EditIssueFn` function has been fixed to properly handle the `[]interface{}` type that comes from the MCP framework:

1. Check if the assignees argument exists in the request
2. Type-assert it to `[]interface{}`
3. Iterate through each element and convert it to string
4. Assign the properly parsed string slice to `opt.Assignees`

## Changes
- Modified `operation/issue/issue.go` in the `EditIssueFn` function
- The fix follows the same pattern used successfully in other parts of the codebase (pull/pull.go and label/label.go)

## Testing
- The fix has been implemented and tested to ensure assignees are properly parsed and applied to issues
- No existing functionality was broken
- The solution maintains backward compatibility

## Impact
This fix resolves the issue where assignees were not being set when using the Gitea-MCP endpoint `/repos/{owner}/{repo}/issues/{index} (PATCH)` to edit issues with assignees.

Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/109
Co-authored-by: Stanislav Krasnyi <stan.krasnyi@gmail.com>
Co-committed-by: Stanislav Krasnyi <stan.krasnyi@gmail.com>
This commit is contained in:
Stanislav Krasnyi
2025-12-13 08:37:15 +00:00
committed by hiifong
parent bdd9fb1816
commit 8b06d7154e

View File

@@ -283,10 +283,17 @@ func EditIssueFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolRes
if ok { if ok {
opt.Body = ptr.To(body) opt.Body = ptr.To(body)
} }
assignees, ok := req.GetArguments()["assignees"].([]string) var assignees []string
if ok { if assigneesArg, exists := req.GetArguments()["assignees"]; exists {
opt.Assignees = assignees if assigneesSlice, ok := assigneesArg.([]interface{}); ok {
for _, assignee := range assigneesSlice {
if assigneeStr, ok := assignee.(string); ok {
assignees = append(assignees, assigneeStr)
}
}
}
} }
opt.Assignees = assignees
milestone, ok := req.GetArguments()["milestone"].(float64) milestone, ok := req.GetArguments()["milestone"].(float64)
if ok { if ok {
opt.Milestone = ptr.To(int64(milestone)) opt.Milestone = ptr.To(int64(milestone))