Skip to content

Commit

Permalink
fix: regexp var
Browse files Browse the repository at this point in the history
  • Loading branch information
iwilltry42 committed Jan 7, 2025
1 parent ab6f22f commit 384c9dc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/controller/handlers/toolreference/toolreference.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import (

var log = logger.Package()

var jsonErrRegexp = regexp.MustCompile(`\{.*"error":.*}`)

type indexEntry struct {
Reference string `json:"reference,omitempty"`
All bool `json:"all,omitempty"`
Expand Down Expand Up @@ -455,8 +457,7 @@ func (h *Handler) BackPopulateModels(req router.Request, _ router.Response) erro
// Also, the toolRef.Status.Error field will bubble up to the user in the UI.

// Check if the model provider returned a properly formatted error message and set it as status
re := regexp.MustCompile(`\{.*"error":.*}`)
match := re.FindString(err.Error())
match := jsonErrRegexp.FindString(err.Error())
if match != "" {
toolRef.Status.Error = match
type errorResponse struct {
Expand Down

0 comments on commit 384c9dc

Please sign in to comment.