Skip to content

Commit 15d1c7e

Browse files
authored
Fix NPEs in search index updates. (#1985)
1 parent 4b855d8 commit 15d1c7e

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

app/lib/search/backend.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ class SearchBackend {
7171

7272
final pubDataFutures = Future.wait<String>(
7373
packages.map(
74-
(p) => dartdocClient.getTextContent(p.name, 'latest', 'pub-data.json',
75-
timeout: const Duration(minutes: 1)),
74+
(p) => p == null
75+
? Future<String>.value()
76+
: dartdocClient.getTextContent(p.name, 'latest', 'pub-data.json',
77+
timeout: const Duration(minutes: 1)),
7678
),
7779
);
7880

app/lib/search/updater.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ class BatchIndexUpdater implements TaskRunner {
136136

137137
await _updateSnapshotIfNeeded(docs);
138138
}
139+
} catch (e, st) {
140+
_logger.warning('Index update error.', e, st);
141+
rethrow;
139142
} finally {
140143
completer.complete();
141144
_ongoingBatchUpdate = null;

app/lib/shared/analyzer_client.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class AnalyzerClient {
3636
}
3737

3838
Future<AnalysisView> getAnalysisView(AnalysisKey key) async {
39+
if (key == null) {
40+
return null;
41+
}
3942
final card = await scoreCardBackend
4043
.getScoreCardData(key.package, key.version, onlyCurrent: false);
4144
if (card == null) {

0 commit comments

Comments
 (0)