Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore(mcp): satisfy revive lint rules

johnnyjoyghe963d326abbd
diff --git a/server/router/mcp/catalog_test.go b/server/router/mcp/catalog_test.go
index 09c346f3d..099973679 100644
--- a/server/router/mcp/catalog_test.go
+++ b/server/router/mcp/catalog_test.go
@@ -424,6 +424,8 @@ func TestBuildCuratedToolsUseStandardSchemaFormats(t *testing.T) {
for index, item := range typed {
collectFormats(t, tool, path+"/"+strconv.Itoa(index), item)
}
+ default:
+ // Scalars carry no nested schemas.
}
}
diff --git a/server/router/mcp/openapi.go b/server/router/mcp/openapi.go
index ca8ac7da7..89aabf465 100644
--- a/server/router/mcp/openapi.go
+++ b/server/router/mcp/openapi.go
@@ -208,6 +208,8 @@ func normalizeSchemaFormat(schema map[string]any) {
case "bytes":
delete(schema, "format")
schema["contentEncoding"] = "base64"
+ default:
+ // Standard JSON Schema formats (date-time, int64, ...) pass through.
}
}
diff --git a/server/router/mcp/openapi_test.go b/server/router/mcp/openapi_test.go
index 194147669..59424ce95 100644
--- a/server/router/mcp/openapi_test.go
+++ b/server/router/mcp/openapi_test.go
@@ -211,13 +211,16 @@ func TestResolveSchemaRefNormalizesNonStandardFormats(t *testing.T) {
schema, err := resolveSchemaRef(spec, jsonSchema{"$ref": "#/components/schemas/Attachment"})
require.NoError(t, err)
- properties := schema["properties"].(map[string]any)
+ properties, ok := schema["properties"].(map[string]any)
+ require.True(t, ok)
- state := properties["state"].(map[string]any)
+ state, ok := properties["state"].(map[string]any)
+ require.True(t, ok)
require.NotContains(t, state, "format")
require.Equal(t, []any{"NORMAL", "ARCHIVED"}, state["enum"])
- content := properties["content"].(map[string]any)
+ content, ok := properties["content"].(map[string]any)
+ require.True(t, ok)
require.NotContains(t, content, "format")
require.Equal(t, "base64", content["contentEncoding"])
@@ -229,7 +232,8 @@ func TestResolveSchemaRefNormalizesNonStandardFormats(t *testing.T) {
func TestSanitizeSchemaValueDoesNotMutateInput(t *testing.T) {
original := jsonSchema{"type": "string", "format": "enum", "items": map[string]any{"format": "bytes"}}
- sanitized := sanitizeSchemaValue(original).(map[string]any)
+ sanitized, ok := sanitizeSchemaValue(original).(map[string]any)
+ require.True(t, ok)
require.NotContains(t, sanitized, "format")
require.Equal(t, "base64", sanitized["items"].(map[string]any)["contentEncoding"])
diff --git a/server/router/mcp/service.go b/server/router/mcp/service.go
index 554c61025..6721ba97d 100644
--- a/server/router/mcp/service.go
+++ b/server/router/mcp/service.go
@@ -111,6 +111,8 @@ func catalogCacheMiddleware(next sdkmcp.MethodHandler) sdkmcp.MethodHandler {
typed.TTLMs = int(toolCatalogTTL.Milliseconds())
case *sdkmcp.DiscoverResult:
typed.TTLMs = int(toolCatalogTTL.Milliseconds())
+ default:
+ // Other results carry no catalog TTL.
}
return result, nil
}
diff --git a/server/router/mcp/service_test.go b/server/router/mcp/service_test.go
index 249a429b3..839eca118 100644
--- a/server/router/mcp/service_test.go
+++ b/server/router/mcp/service_test.go
@@ -568,7 +568,8 @@ func TestMCPRequestBodyLimitMatchesAPI(t *testing.T) {
echoServer.POST("/api/v1/attachments", func(c *echo.Context) error {
body := map[string]any{}
require.NoError(t, json.NewDecoder(c.Request().Body).Decode(&body))
- content, _ := body["content"].(string)
+ content, ok := body["content"].(string)
+ require.True(t, ok)
receivedBytes = len(content)
return c.JSON(http.StatusOK, map[string]any{"name": "attachments/1"})
})