Skip to content

Commit

Permalink
Fix overly specific detection of non-UTF8 files in analyzer bot. (#56295
Browse files Browse the repository at this point in the history
)

An upcoming Dart SDK change
(dart-lang/sdk@fa2fd41)
changes the precise text of the exception generated by `utf8.decode`
if a non-UTF8 file is found.  This is causing a breakage in the Dart
team's `flutter-analyze` bot (and will presumably cause a breakage in
the corresponding Flutter bot as soon as this change is rolled into
Flutter).  To avoid this breakage, the bot shouldn't rely on the exact
exception text; it is sufficient to simply catch a FormatException.
  • Loading branch information
stereotype441 committed May 4, 2020
1 parent 8f1cd8f commit c32d138
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions dev/bots/analyze.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1086,13 +1086,9 @@ Future<void> verifyNoBinaries(String workingDirectory, { Set<Hash256> grandfathe
try {
utf8.decode(bytes);
} on FormatException catch (error) {
if (error.message.startsWith('Bad UTF-8 encoding ')) {
final Digest digest = sha256.convert(bytes);
if (!grandfatheredBinaries.contains(Hash256.fromDigest(digest)))
problems.add('${file.path}:${error.offset}: file is not valid UTF-8');
} else {
rethrow;
}
final Digest digest = sha256.convert(bytes);
if (!grandfatheredBinaries.contains(Hash256.fromDigest(digest)))
problems.add('${file.path}:${error.offset}: file is not valid UTF-8');
}
}
if (problems.isNotEmpty) {
Expand Down

0 comments on commit c32d138

Please sign in to comment.