{"record":{"id":"b26eea8acde32091","repo":"Tencent/WeKnora","slug":"mcp-service-not-found","errorCode":null,"errorMessage":"MCP service not found","messagePattern":"MCP service not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/mcp_service.go","lineNumber":546,"sourceCode":"\ts.mcpManager.CloseClient(id)\n\tlogger.GetLogger(ctx).Infof(\n\t\t\"MCP credentials updated, connection closed: %s (ID: %s)\",\n\t\tsecutils.SanitizeForLog(existing.Name), id,\n\t)\n\treturn existing, nil\n}\n\n// ClearMCPCredential removes a single credential field. Idempotent: clearing\n// an already-empty field returns nil without writing or reconnecting.\nfunc (s *mcpServiceService) ClearMCPCredential(\n\tctx context.Context, tenantID uint64, id, field string,\n) error {\n\texisting, err := s.mcpServiceRepo.GetByID(ctx, tenantID, id)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get MCP service: %w\", err)\n\t}\n\tif existing == nil {\n\t\treturn fmt.Errorf(\"MCP service not found\")\n\t}\n\tif existing.IsBuiltin {\n\t\treturn fmt.Errorf(\"builtin MCP services cannot have credentials modified\")\n\t}\n\tif existing.AuthConfig == nil {\n\t\treturn nil // nothing to clear\n\t}\n\n\tchanged := false\n\tswitch field {\n\tcase \"api_key\":\n\t\tif existing.AuthConfig.APIKey != \"\" {\n\t\t\texisting.AuthConfig.APIKey = \"\"\n\t\t\tchanged = true\n\t\t}\n\tcase \"token\":\n\t\tif existing.AuthConfig.Token != \"\" {\n\t\t\texisting.AuthConfig.Token = \"\"","sourceCodeStart":528,"sourceCodeEnd":564,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/mcp_service.go#L528-L564","documentation":"Lookup guard in mcpServiceService.ClearMCPCredential: the tenant-scoped repository GetByID returned nil for the requested MCP service ID, meaning no such service exists in this workspace. The method cannot clear a credential on a nonexistent entity, so it aborts before touching AuthConfig; distinct from a repo error, which would surface as 'failed to get MCP service'.","triggerScenarios":"Thrown at internal/application/service/mcp_service.go:546 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the MCP service ID and that it belongs to the tenant","List MCP services to confirm the record still exists","Return/propagate a 404-style response to the caller"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}