chore: fix linter issues (#1859)

This commit is contained in:
Dr. Strangelove
2025-11-05 12:27:31 -05:00
committed by GitHub
parent 954152c792
commit 50c400063b
11 changed files with 64 additions and 70 deletions

View File

@@ -1349,7 +1349,6 @@ func TestPrebuiltTools(t *testing.T) {
t.Setenv("NEO4J_USERNAME", "your_neo4j_user")
t.Setenv("NEO4J_PASSWORD", "your_neo4j_password")
ctx, err := testutils.ContextWithNewLogger()
if err != nil {
t.Fatalf("unexpected error: %s", err)
@@ -1566,10 +1565,10 @@ func TestPrebuiltTools(t *testing.T) {
"mindsdb-tools": tools.ToolsetConfig{
Name: "mindsdb-tools",
ToolNames: []string{"mindsdb-execute-sql", "mindsdb-sql"},
},
},
},
},
{
{
name: "sqlite prebuilt tools",
in: sqlite_config,
wantToolset: server.ToolsetConfigs{

View File

@@ -198,12 +198,12 @@ func TestGetPrebuiltTool(t *testing.T) {
if len(mindsdb_config) <= 0 {
t.Fatalf("unexpected error: could not fetch spanner pg prebuilt tools yaml")
}
}
if len(sqlite_config) <= 0 {
t.Fatalf("unexpected error: could not fetch sqlite prebuilt tools yaml")
}
if len(neo4jconfig) <= 0 {
t.Fatalf("unexpected error: could not fetch neo4j prebuilt tools yaml")
}

View File

@@ -212,15 +212,15 @@ func getURL(baseURL, path string, pathParams, queryParams tools.Parameters, defa
for _, p := range queryParams {
v, ok := paramsMap[p.GetName()]
if !ok || v == nil {
if !p.GetRequired(){
if !p.GetRequired() {
// If the param is not required AND
// Not provodid OR provided with a nil value
// Not provodid OR provided with a nil value
// Omitted from the URL
continue
}
v = ""
}
query.Add(p.GetName(), fmt.Sprintf("%v", v))
}
query.Add(p.GetName(), fmt.Sprintf("%v", v))
}
parsedURL.RawQuery = query.Encode()
return parsedURL.String(), nil
@@ -284,7 +284,7 @@ func (t Tool) Invoke(ctx context.Context, params tools.ParamValues, accessToken
return nil, err
}
if resp.StatusCode < 200 || resp.StatusCode > 299 {
return nil, fmt.Errorf("unexpected status code: %d, response body: %s", resp.StatusCode, string(body))
return nil, fmt.Errorf("unexpected status code: %d, response body: %s", resp.StatusCode, string(body))
}
var data any

View File

@@ -166,4 +166,4 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool {
func (t Tool) RequiresClientAuthorization() bool {
return t.UseClientOAuth
}
}

View File

@@ -156,4 +156,4 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool {
func (t Tool) RequiresClientAuthorization() bool {
return t.UseClientOAuth
}
}

View File

@@ -163,4 +163,4 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool {
func (t Tool) RequiresClientAuthorization() bool {
return t.UseClientOAuth
}
}

View File

@@ -90,7 +90,7 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
Parameters: parameters.Manifest(),
AuthRequired: cfg.AuthRequired,
},
mcpManifest: mcpManifest,
mcpManifest: mcpManifest,
}, nil
}
@@ -98,15 +98,15 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
var _ tools.Tool = Tool{}
type Tool struct {
Name string `yaml:"name"`
Kind string `yaml:"kind"`
UseClientOAuth bool
Client *v4.LookerSDK
ApiSettings *rtl.ApiSettings
AuthRequired []string `yaml:"authRequired"`
Parameters tools.Parameters `yaml:"parameters"`
manifest tools.Manifest
mcpManifest tools.McpManifest
Name string `yaml:"name"`
Kind string `yaml:"kind"`
UseClientOAuth bool
Client *v4.LookerSDK
ApiSettings *rtl.ApiSettings
AuthRequired []string `yaml:"authRequired"`
Parameters tools.Parameters `yaml:"parameters"`
manifest tools.Manifest
mcpManifest tools.McpManifest
}
func (t Tool) Invoke(ctx context.Context, params tools.ParamValues, accessToken tools.AccessToken) (any, error) {
@@ -147,4 +147,4 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool {
func (t Tool) RequiresClientAuthorization() bool {
return t.UseClientOAuth
}
}

View File

@@ -90,7 +90,7 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
Parameters: parameters.Manifest(),
AuthRequired: cfg.AuthRequired,
},
mcpManifest: mcpManifest,
mcpManifest: mcpManifest,
}, nil
}
@@ -98,15 +98,15 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
var _ tools.Tool = Tool{}
type Tool struct {
Name string `yaml:"name"`
Kind string `yaml:"kind"`
UseClientOAuth bool
Client *v4.LookerSDK
ApiSettings *rtl.ApiSettings
AuthRequired []string `yaml:"authRequired"`
Parameters tools.Parameters `yaml:"parameters"`
manifest tools.Manifest
mcpManifest tools.McpManifest
Name string `yaml:"name"`
Kind string `yaml:"kind"`
UseClientOAuth bool
Client *v4.LookerSDK
ApiSettings *rtl.ApiSettings
AuthRequired []string `yaml:"authRequired"`
Parameters tools.Parameters `yaml:"parameters"`
manifest tools.Manifest
mcpManifest tools.McpManifest
}
func (t Tool) Invoke(ctx context.Context, params tools.ParamValues, accessToken tools.AccessToken) (any, error) {
@@ -119,7 +119,7 @@ func (t Tool) Invoke(ctx context.Context, params tools.ParamValues, accessToken
if err != nil {
return nil, fmt.Errorf("error getting sdk: %w", err)
}
resp, err := sdk.AllConnections("name, dialect(name), database, schema",t.ApiSettings)
resp, err := sdk.AllConnections("name, dialect(name), database, schema", t.ApiSettings)
if err != nil {
return nil, fmt.Errorf("error making get_connections request: %s", err)
}

View File

@@ -153,4 +153,4 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool {
func (t Tool) RequiresClientAuthorization() bool {
return t.UseClientOAuth
}
}

View File

@@ -166,4 +166,4 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool {
func (t Tool) RequiresClientAuthorization() bool {
return t.UseClientOAuth
}
}

View File

@@ -79,22 +79,22 @@ func multiTool(w http.ResponseWriter, r *http.Request) {
// handleQueryTest simply returns the raw query string it received so the test
// can verify it's formatted correctly.
func handleQueryTest(w http.ResponseWriter, r *http.Request) {
// expect GET method
if r.Method != http.MethodGet {
errorMessage := fmt.Sprintf("expected GET method but got: %s", string(r.Method))
http.Error(w, errorMessage, http.StatusBadRequest)
return
}
// expect GET method
if r.Method != http.MethodGet {
errorMessage := fmt.Sprintf("expected GET method but got: %s", string(r.Method))
http.Error(w, errorMessage, http.StatusBadRequest)
return
}
w.WriteHeader(http.StatusOK)
enc := json.NewEncoder(w)
enc.SetEscapeHTML(false)
w.WriteHeader(http.StatusOK)
enc := json.NewEncoder(w)
enc.SetEscapeHTML(false)
err := enc.Encode(r.URL.RawQuery)
if err != nil {
http.Error(w, "Failed to write response", http.StatusInternalServerError)
return
}
err := enc.Encode(r.URL.RawQuery)
if err != nil {
http.Error(w, "Failed to write response", http.StatusInternalServerError)
return
}
}
// handler function for the test server
@@ -579,31 +579,26 @@ func getHTTPToolsConfig(sourceConfig map[string]any, toolKind string) map[string
"method": "get",
"path": "/{{.path}}?id=2",
"description": "some description",
"headers":
map[string]string{
"X-Custom-Header": "example",
},
"pathParams":
[]tools.Parameter{
&tools.StringParameter{
CommonParameter: tools.CommonParameter{Name: "path", Type: "string", Desc: "path param"},
},
},
"queryParams":
[]tools.Parameter{
tools.NewIntParameter("id", "user ID"), tools.NewStringParameter("country", "country"),
"headers": map[string]string{
"X-Custom-Header": "example",
},
"pathParams": []tools.Parameter{
&tools.StringParameter{
CommonParameter: tools.CommonParameter{Name: "path", Type: "string", Desc: "path param"},
},
},
"queryParams": []tools.Parameter{
tools.NewIntParameter("id", "user ID"), tools.NewStringParameter("country", "country"),
},
"requestBody": `{
"place": "zoo",
"animals": {{json .animalArray }}
}
`,
"bodyParams":
[]tools.Parameter{tools.NewArrayParameter("animalArray", "animals in the zoo", tools.NewStringParameter("animals", "desc"))},
"headerParams":
[]tools.Parameter{tools.NewStringParameter("X-Other-Header", "custom header")},
"bodyParams": []tools.Parameter{tools.NewArrayParameter("animalArray", "animals in the zoo", tools.NewStringParameter("animals", "desc"))},
"headerParams": []tools.Parameter{tools.NewStringParameter("X-Other-Header", "custom header")},
},
},
}
return toolsFile
}
}