Skip to content

Commit

Permalink
Prevent bad query strings from LLM
Browse files Browse the repository at this point in the history
  • Loading branch information
crspeller committed Aug 5, 2024
1 parent aabcab0 commit f5ef15d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion server/built_in_tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"io"
"net/http"
"net/url"
"regexp"
"strings"
"time"
Expand Down Expand Up @@ -165,7 +166,14 @@ func (p *Plugin) toolGetGithubIssue(context ai.ConversationContext, argsGetter a
return "invalid parameters to function", errors.New("invalid issue number")
}

req, err := http.NewRequest("GET", fmt.Sprintf("/github/api/v1/issue?owner=%s&repo=%s&number=%d", args.RepoOwner, args.RepoName, args.Number), nil)
req, err := http.NewRequest("GET",
fmt.Sprintf("/github/api/v1/issue?owner=%s&repo=%s&number=%d",
url.QueryEscape(args.RepoOwner),
url.QueryEscape(args.RepoName),
args.Number,
),
nil,
)
if err != nil {
return "internal failure", fmt.Errorf("failed to create request: %w", err)
}
Expand Down

0 comments on commit f5ef15d

Please sign in to comment.