Skip to content

Commit fe1d3b6

Browse files
Michael McNeesclaude
authored andcommitted
fix: address Copilot review feedback on PR #142
- Validate priority range (0–4) in linear/create_issue; return error early - Replace duplicate extractIntParam with shared extractInt (handles int64) - Rename shadowed body var to respBody in github/dispatch error path - Add TestLinearCreateIssueConnector_InvalidPriority test Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ab94844 commit fe1d3b6

3 files changed

Lines changed: 20 additions & 14 deletions

File tree

packages/engine/internal/connector/github.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ func (c *GitHubDispatchConnector) Execute(ctx context.Context, params map[string
167167

168168
// GitHub returns 204 No Content on success.
169169
if resp.StatusCode != http.StatusNoContent {
170-
body, _ := io.ReadAll(io.LimitReader(resp.Body, 500))
171-
return nil, fmt.Errorf("github/dispatch: GitHub API returned %d: %s", resp.StatusCode, truncate(string(body), 500))
170+
respBody, _ := io.ReadAll(io.LimitReader(resp.Body, 500))
171+
return nil, fmt.Errorf("github/dispatch: GitHub API returned %d: %s", resp.StatusCode, truncate(string(respBody), 500))
172172
}
173173

174174
return map[string]any{"ok": true}, nil

packages/engine/internal/connector/linear.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ func (c *LinearCreateIssueConnector) Execute(ctx context.Context, params map[str
5252
if projectID, ok := params["project_id"].(string); ok && projectID != "" {
5353
input["projectId"] = projectID
5454
}
55-
if priority, ok := extractIntParam(params["priority"]); ok {
55+
if priority, ok := extractInt(params["priority"]); ok {
56+
if priority < 0 || priority > 4 {
57+
return nil, fmt.Errorf("linear/create_issue: priority must be between 0 and 4, got %d", priority)
58+
}
5659
input["priority"] = priority
5760
}
5861
if labelIDs := toStringSlice(params["label_ids"]); len(labelIDs) > 0 {
@@ -117,7 +120,7 @@ func (c *LinearSearchConnector) Execute(ctx context.Context, params map[string]a
117120
}
118121

119122
limit := 25
120-
if l, ok := extractIntParam(params["limit"]); ok && l > 0 {
123+
if l, ok := extractInt(params["limit"]); ok && l > 0 {
121124
limit = l
122125
}
123126

@@ -235,13 +238,3 @@ func extractLinearToken(params map[string]any) (string, error) {
235238
return token, nil
236239
}
237240

238-
// extractIntParam extracts an integer from float64 (JSON default) or int.
239-
func extractIntParam(v any) (int, bool) {
240-
switch n := v.(type) {
241-
case int:
242-
return n, true
243-
case float64:
244-
return int(n), true
245-
}
246-
return 0, false
247-
}

packages/engine/internal/connector/linear_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,19 @@ func TestLinearCreateIssueConnector_MissingTitle(t *testing.T) {
103103
}
104104
}
105105

106+
func TestLinearCreateIssueConnector_InvalidPriority(t *testing.T) {
107+
c := &LinearCreateIssueConnector{}
108+
_, err := c.Execute(context.Background(), map[string]any{
109+
"team_id": "team-uuid",
110+
"title": "Test",
111+
"priority": float64(5),
112+
"_credential": map[string]string{"token": "lin_api_test"},
113+
})
114+
if err == nil {
115+
t.Fatal("expected error for priority out of range")
116+
}
117+
}
118+
106119
func TestLinearCreateIssueConnector_MissingCredential(t *testing.T) {
107120
c := &LinearCreateIssueConnector{}
108121
_, err := c.Execute(context.Background(), map[string]any{

0 commit comments

Comments
 (0)