@@ -3,6 +3,7 @@ package github
33import (
44 "context"
55 "net/http"
6+ "strings"
67 "testing"
78
89 "github.com/github/github-mcp-server/internal/githubv4mock"
@@ -328,7 +329,7 @@ func TestGranularUpdateIssueType(t *testing.T) {
328329 "repo" : "repo" ,
329330 "issue_number" : float64 (1 ),
330331 "issue_type" : "feature" ,
331- "rationale" : "This issue requests a new capability" ,
332+ "rationale" : " This issue requests a new capability " ,
332333 },
333334 expectedReq : map [string ]any {
334335 "type" : map [string ]any {
@@ -357,6 +358,52 @@ func TestGranularUpdateIssueType(t *testing.T) {
357358 }
358359}
359360
361+ func TestGranularUpdateIssueTypeInvalidRationale (t * testing.T ) {
362+ tests := []struct {
363+ name string
364+ requestArgs map [string ]any
365+ expectedErrText string
366+ }{
367+ {
368+ name : "rationale wrong type" ,
369+ requestArgs : map [string ]any {
370+ "owner" : "owner" ,
371+ "repo" : "repo" ,
372+ "issue_number" : float64 (1 ),
373+ "issue_type" : "feature" ,
374+ "rationale" : float64 (123 ),
375+ },
376+ expectedErrText : "parameter rationale is not of type string, is float64" ,
377+ },
378+ {
379+ name : "rationale too long" ,
380+ requestArgs : map [string ]any {
381+ "owner" : "owner" ,
382+ "repo" : "repo" ,
383+ "issue_number" : float64 (1 ),
384+ "issue_type" : "feature" ,
385+ "rationale" : strings .Repeat ("a" , 281 ),
386+ },
387+ expectedErrText : "parameter rationale must be 280 characters or less" ,
388+ },
389+ }
390+
391+ for _ , tc := range tests {
392+ t .Run (tc .name , func (t * testing.T ) {
393+ deps := BaseDeps {Client : gogithub .NewClient (MockHTTPClientWithHandlers (nil ))}
394+ serverTool := GranularUpdateIssueType (translations .NullTranslationHelper )
395+ handler := serverTool .Handler (deps )
396+
397+ request := createMCPRequest (tc .requestArgs )
398+ result , err := handler (ContextWithDeps (context .Background (), deps ), & request )
399+ require .NoError (t , err )
400+
401+ errorContent := getErrorResult (t , result )
402+ assert .Contains (t , errorContent .Text , tc .expectedErrText )
403+ })
404+ }
405+ }
406+
360407func TestGranularUpdateIssueState (t * testing.T ) {
361408 tests := []struct {
362409 name string
0 commit comments