Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions app/lib/frontend/handlers/custom_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,7 @@ const _commonLicenses = [
/// Handles requests for /api/search
Future<shelf.Response> apiSearchHandler(shelf.Request request) async {
final searchForm = SearchForm.parse(request.requestedUri.queryParameters);
final sr = await searchClient.search(
searchForm.toServiceQuery(),
sourceIp: request.sourceIp,
);
final sr = await searchClient.search(searchForm.toServiceQuery());
final packages = sr.packageHits.map((ps) => {'package': ps.package}).toList();
final hasNextPage = sr.totalCount > searchForm.pageSize! + searchForm.offset;
final result = <String, dynamic>{
Expand Down
5 changes: 1 addition & 4 deletions app/lib/package/search_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ class SearchAdapter {
) async {
PackageSearchResult? result;
try {
result = await searchClient.search(
searchForm.toServiceQuery(),
sourceIp: sourceIp,
);
result = await searchClient.search(searchForm.toServiceQuery());
} on RateLimitException {
rethrow;
} catch (e, st) {
Expand Down
2 changes: 0 additions & 2 deletions app/lib/search/backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,6 @@ class SearchBackend {
// Do not cache response at the search client level, as we'll be caching
// it in a processed form much longer.
skipCache: true,
// Do not apply rate limit here.
sourceIp: null,
);
return {'packages': rs.packageHits.map((p) => p.package).toList()};
}
Expand Down
17 changes: 0 additions & 17 deletions app/lib/search/search_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import 'package:_pub_shared/utils/http.dart';
import 'package:clock/clock.dart';
import 'package:gcloud/service_scope.dart' as ss;

import '../../../service/rate_limit/rate_limit.dart';
import '../../account/like_backend.dart';
import '../../frontend/request_context.dart';
import '../shared/configuration.dart';
Expand All @@ -19,11 +18,6 @@ import '../shared/utils.dart';

import 'search_service.dart';

/// The number of requests allowed over [_searchRateLimitWindow]
const _searchRateLimit = 120;
const _searchRateLimitWindow = Duration(minutes: 2);
const _searchRateLimitWindowAsText = 'last 2 minutes';

/// Sets the search client.
void registerSearchClient(SearchClient client) =>
ss.register(#_searchClient, client);
Expand All @@ -45,7 +39,6 @@ class SearchClient {
/// Calls the search service (or uses cache) to serve the [query].
Future<PackageSearchResult> search(
ServiceSearchQuery query, {
required String? sourceIp,
bool skipCache = false,
}) async {
// check validity first
Expand Down Expand Up @@ -170,16 +163,6 @@ class SearchClient {
);
}

if (sourceIp != null) {
await verifyRequestCounts(
sourceIp: sourceIp,
operation: 'search',
limit: _searchRateLimit,
window: _searchRateLimitWindow,
windowAsText: _searchRateLimitWindowAsText,
);
}

if (skipCache) {
return await searchFn();
} else {
Expand Down
59 changes: 0 additions & 59 deletions app/test/search/search_rate_limit_test.dart

This file was deleted.